mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
* src/reader.c (grammar_current_rule_check): Also check that $$
is used. Take the rule to check as argument, hence rename as... (grammar_rule_check): this. * src/reader.h, src/reader.c (grammar_rule_begin, grammar_rule_end): Rename as... (grammar_rule_begin, grammar_rule_end): these, for consistency. (grammar_midrule_action, grammar_symbol_append): Now static. * tests/torture.at (input): Don't rely on the default action being always performed. * tests/calc.at: "Set" $$ even when the action is "cut" with YYERROR or other. * tests/actions.at (Exotic Dollars): Instead of using unused values, check that the warning is issued.
This commit is contained in:
10
NEWS
10
NEWS
@@ -7,13 +7,13 @@ Changes in version 2.1a:
|
||||
Typed right-hand side symbols whose value are not used are reported.
|
||||
For instance:
|
||||
|
||||
exp: exp "?" exp ":" exp { $$ = $1 ? $1 : $3; }
|
||||
exp: exp "?" exp ":" exp { $1 ? $1 : $3; }
|
||||
| exp "+" exp
|
||||
;
|
||||
|
||||
will trigger a warning about $5 of the first rule, and $3 in the
|
||||
second ($1 is copied to $$ by the default rule). This example
|
||||
most likely contains two errors, and should be rewritten as:
|
||||
will trigger a warning about $$ and $5 in the first rule, and $3 in
|
||||
the second ($1 is copied to $$ by the default rule). This example
|
||||
most likely contains three errors, and should be rewritten as:
|
||||
|
||||
exp: exp "?" exp ":" exp { $$ = $1 ? $3 : $5; }
|
||||
| exp "+" exp { $$ = $1 + $3; }
|
||||
@@ -22,7 +22,7 @@ Changes in version 2.1a:
|
||||
However, if the original actions were really intended, the warnings
|
||||
can be suppressed by letting Bison believe the values are used, e.g.:
|
||||
|
||||
exp: exp "?" exp ":" exp { $$ = $1 ? $1 : $3; (void) $5; }
|
||||
exp: exp "?" exp ":" exp { $1 ? $1 : $3; (void) ($$, $5); }
|
||||
| exp "+" exp { $$ = $1; (void) $3; }
|
||||
;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user