-/* Check that the last rule (CURRENT_RULE) is properly defined. For
- instance, there should be no type clash on the default action. */
+
+/*----------------------------------------------------------------------.
+| A symbol should be used if it has a destructor, or if it is a |
+| mid-rule symbol (i.e., the generated LHS replacing a mid-rule |
+| action) that was assigned to, as in "exp: { $$ = 1; } { $$ = $1; }". |
+`----------------------------------------------------------------------*/
+
+static bool
+symbol_should_be_used (symbol_list const *s)
+{
+ return (s->sym->destructor
+ || (s->midrule && s->midrule->used));
+}
+
+/*----------------------------------------------------------------.
+| Check that the rule R is properly defined. For instance, there |
+| should be no type clash on the default action. |
+`----------------------------------------------------------------*/