mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 05:13:04 +00:00
-Wempty-rule: diagnose empty rules without %empty
* src/complain.h, src/complain.c (warning_empty_rule, Wempty_rule): New warning category. (warnings_args, warnings_types): Adjust. * src/reader.c (grammar_rule_check): Check the empty rules are flagged by %empty. * tests/actions.at (Implicitly empty rule): New. * tests/existing.at: Add expected warnings.
This commit is contained in:
@@ -339,6 +339,12 @@ grammar_rule_check (const symbol_list *r)
|
||||
complain (&r->percent_empty_loc, complaint,
|
||||
_("%%empty on non-empty rule"));
|
||||
|
||||
/* Check that empty rule => %empty. */
|
||||
if (!(r->next && r->next->content.sym)
|
||||
&& !r->midrule_parent_rule
|
||||
&& !r->percent_empty_loc.start.file)
|
||||
complain (&r->location, Wempty_rule, _("empty rule without %%empty"));
|
||||
|
||||
/* See comments in grammar_current_rule_prec_set for how POSIX
|
||||
mandates this complaint. It's only for identifiers, so skip
|
||||
it for char literals and strings, which are always tokens. */
|
||||
|
||||
Reference in New Issue
Block a user