mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 21:03:04 +00:00
warnings: raise warning for useless printers or destructors
* src/scan-code.h (code_props): Add field 'is_used'. (CODE_PROPS_NONE_INIT): Adjust. * src/scan-code.l (code_props_plain_init, code_props_symbol_action_init) (code_props_rule_action_init): Instead of implementing several times the initialization of the code_props structures, use code_props_none_init. * src/symtab.c (symbol_check_defined): If a symbol does not have a destructor (resp. printer) but has a type which has a destructor (resp. printer), then set field 'is_used' to true. (semantic_type_check_defined): If a type has a destructor (resp. printer) but all symbols of this type have already a destructor (resp. printer), then raise a warning. * tests/input.at (Useless printers or destructors): New. Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
This commit is contained in:
committed by
Akim Demaille
parent
9641b918ba
commit
ea9a35c605
@@ -323,6 +323,51 @@ input.y:5.25-31: warning: type <type4> is used, but is not associated to any sym
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## --------------------------------- ##
|
||||
## Useless printers or destructors. ##
|
||||
## --------------------------------- ##
|
||||
|
||||
AT_SETUP([Useless printers or destructors])
|
||||
|
||||
AT_DATA([[input.y]],
|
||||
[[%token <type1> token1
|
||||
%token <type2> token2
|
||||
%token <type3> token3
|
||||
%token <type4> token4
|
||||
%token <type5> token51 token52
|
||||
%token <type6> token61 token62
|
||||
%token <type7> token7
|
||||
|
||||
%printer {} token1
|
||||
%destructor {} token2
|
||||
%printer {} token51
|
||||
%destructor {} token61
|
||||
|
||||
%printer {} token7
|
||||
|
||||
%printer {} <type1>
|
||||
%destructor {} <type2>
|
||||
%printer {} <type3>
|
||||
%destructor {} <type4>
|
||||
|
||||
%printer {} <type5>
|
||||
%destructor {} <type6>
|
||||
|
||||
%destructor {} <type7>
|
||||
|
||||
%%
|
||||
exp: "a";
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([input.y], [0], [],
|
||||
[[input.y:16.13-19: warning: useless %printer for type <type1>
|
||||
input.y:17.16-22: warning: useless %destructor for type <type2>
|
||||
]])
|
||||
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## ---------------------------------------- ##
|
||||
## Unused values with default %destructor. ##
|
||||
## ---------------------------------------- ##
|
||||
|
||||
Reference in New Issue
Block a user