mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 17:23:02 +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:
@@ -64,6 +64,28 @@ AT_PARSER_CHECK([./input], 0,
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
## ----------------------- ##
|
||||
## Implicitly empty rule. ##
|
||||
## ----------------------- ##
|
||||
|
||||
AT_SETUP([Implicitly empty rule])
|
||||
|
||||
AT_DATA_GRAMMAR([[1.y]],
|
||||
[[%%
|
||||
exp: a b;
|
||||
a: /* empty. */ {};
|
||||
// A mid-rule action does not count as an empty rule.
|
||||
b: {} {};
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([-fcaret -Wempty-rule 1.y], [0], [],
|
||||
[[1.y:11.17-18: warning: empty rule without %empty [-Wempty-rule]
|
||||
a: /* empty. */ {};
|
||||
^^
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
## ------------------------ ##
|
||||
## Invalid uses of %empty. ##
|
||||
## ------------------------ ##
|
||||
|
||||
Reference in New Issue
Block a user