mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 12:53:03 +00:00
fix warnings for useless %printer/%destructor
The previous commit, which turns into a warning what used to be an
error:
%printer {} foo;
%%
exp: '0';
has two shortcomings: the warning is way too long (foo is reported
to be useless later), and besides, it also turns into a warning much
more serious errors:
%printer {} foo;
%%
exp: foo;
Reduce the amount to warnings in the first case, restore the error in
the second.
* src/symtab.h (status): Add a new inital state: undeclared.
* src/symtab.c (symbol_new): Initialize to undeclared.
(symbol_class_set): Simplify the logic of the code that neutralize
the "redeclared" warning after the "redefined" one.
(symbol_check_defined): "undeclared" is also an error.
* src/reader.c (grammar_current_rule_symbol_append): Symbols appearing
in a rule are "needed".
* src/symlist.c (symbol_list_destructor_set, symbol_list_printer_set):
An unknown symbol appearing in a %printer/%destructor is "used".
* src/reduce.c (nonterminals_reduce): Do not report as "useless" symbols
that are not used (e.g., those that for instance appeared only in a
%printer).
* tests/input.at (Undeclared symbols used for a printer or destructor):
Improve the cover the cases described above.
This commit is contained in:
@@ -271,26 +271,24 @@ input.y:5.10-24: previous declaration
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
## ---------------------------------------------------- ##
|
||||
## Undeclared symbols used for a printer or destructor. ##
|
||||
## ---------------------------------------------------- ##
|
||||
## ----------------------------------------------------- ##
|
||||
## Undeclared symbols used for a printer or destructor. ##
|
||||
## ----------------------------------------------------- ##
|
||||
|
||||
AT_SETUP([Undeclared symbols used for a printer or destructor])
|
||||
|
||||
AT_DATA([[input.y]],
|
||||
[[%printer {} token1
|
||||
%destructor {} token2
|
||||
[[%printer {} foo baz
|
||||
%destructor {} bar
|
||||
|
||||
%%
|
||||
exp: "a";
|
||||
exp: bar;
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([input.y], [0], [],
|
||||
[[input.y:1.13-18: warning: symbol token1 is used, but is not defined as a token and has no rules
|
||||
input.y:2.16-21: warning: symbol token2 is used, but is not defined as a token and has no rules
|
||||
input.y: warning: 2 nonterminals useless in grammar
|
||||
input.y:1.13-18: warning: nonterminal useless in grammar: token1
|
||||
input.y:2.16-21: warning: nonterminal useless in grammar: token2
|
||||
AT_BISON_CHECK([input.y], [1], [],
|
||||
[[input.y:2.16-18: symbol bar is used, but is not defined as a token and has no rules
|
||||
input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules
|
||||
input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
Reference in New Issue
Block a user