+
+/*----------------------------------------------------------------------.
+| A symbol should be used if either: |
+| 1. It has a destructor. |
+| 2. --warnings=midrule-values and the symbol is a mid-rule symbol |
+| (i.e., the generated LHS replacing a mid-rule action) that was |
+| assigned to or used, as in "exp: { $$ = 1; } { $$ = $1; }". |
+`----------------------------------------------------------------------*/
+
+static bool
+symbol_should_be_used (symbol_list const *s)
+{
+ if (symbol_destructor_get (s->content.sym)->code)
+ return true;
+ if (warnings_flag & warnings_midrule_values)
+ return ((s->midrule && s->midrule->action_props.is_value_used)
+ || (s->midrule_parent_rule
+ && symbol_list_n_get (s->midrule_parent_rule,
+ s->midrule_parent_rhs_index)
+ ->action_props.is_value_used));
+ return false;
+}
+
+/*----------------------------------------------------------------.
+| Check that the rule R is properly defined. For instance, there |
+| should be no type clash on the default action. |
+`----------------------------------------------------------------*/