Also warn about non-used mid-rule values.

* src/symlist.h, src/symlist.c (symbol_list): Add a mid_rule
member.
(symbol_list_new): Adjust.
* src/reader.c (symbol_typed_p): New.
(grammar_rule_check): Use it.
(grammar_midrule_action): Bind a mid-rule LHS to its rule.
Check its rule.
* tests/input.at (AT_CHECK_UNUSED_VALUES): New.
Use it.
* tests/actions.at (Exotic Dollars): Adjust.
This commit is contained in:
Akim Demaille
2006-01-04 09:18:37 +00:00
parent 378f4bd846
commit 8486615972
7 changed files with 115 additions and 42 deletions

11
NEWS
View File

@@ -26,6 +26,17 @@ Changes in version 2.1a:
| exp "+" exp { $$ = $1; (void) $3; }
;
If there are mid-rule actions, the warning is issued if no action
uses it. The following triggers no warning: $1 and $3 are used.
exp: exp { push ($1); } '+' exp { push ($3); sum (); };
Mid-rule actions that use $$ cause the corresponding value to be
set, therefore the following action must use it. The following rule
triggers a warning about $2.
exp: '1' { $$ = 1; } '+' exp { $$ = $1 + $4; };
The warning is intended to help catching lost values and memory leaks.
If a value is ignored, its associated memory typically is not reclaimed.