Error check fragment rules which don't emit anything.
authorDavid Given <dg@cowlark.com>
Thu, 29 Sep 2016 20:14:11 +0000 (22:14 +0200)
committerDavid Given <dg@cowlark.com>
Thu, 29 Sep 2016 20:14:11 +0000 (22:14 +0200)
util/mcgg/iburg.c

index 0e8cad4..1fc0a7c 100644 (file)
@@ -1014,6 +1014,15 @@ static void emitinsndata(Rule rules)
 
                        print("}\n\n");
                }
+               else
+               {
+                       /* This instruction has no code; make sure it's not a fragment. */
+                       if (r->lhs->is_fragment)
+                       {
+                               yylineno = r->lineno;
+                               yyerror("rule is a fragment, but doesn't emit anything");
+                       }
+               }
 
                r = r->link;
        }