mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 05:13:04 +00:00
Fix a longstanding bug uncovered by bro-0.9a9/src/parse.y, which I
got from <http://bro-ids.org/download.html>. The bug is that when two actions appeared in succession, the second one was scanned before the first one was added to the grammar rule as a midrule action. Bison then output the incorrect warning "parse.y:905.17-906.36: warning: unused value: $3". * src/parse-gram.y (BRACED_CODE, action): These are no longer associated with a value. (rhs): Don't invoke grammar_current_rule_action_append. (action): Invoke it here instead. * src/reader.c (grammar_midrule_action): Now extern. (grammar_current_rule_action_append): Don't invoke grammar_midrule_action; that is now the scanner's job. * src/reader.h (last_string, last_braced_code_loc): (grammar_midrule_action): New decls. * src/scan-gram.l (last_string): Now extern, sigh. (last_braced_code_loc): New extern variable. (<INITIAL>"{"): Invoke grammar_midrule_action if the current rule already has an action. (<SC_BRACED_CODE>"}"): Set last_braced_code_loc before returning. * tests/input.at (AT_CHECK_UNUSED_VALUES): Add some tests to check that the above changes fixed the bug.
This commit is contained in:
@@ -300,7 +300,7 @@ grammar_current_rule_end (location loc)
|
||||
| rule. |
|
||||
`-------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
void
|
||||
grammar_midrule_action (void)
|
||||
{
|
||||
/* Since the action was written out with this rule's number, we must
|
||||
@@ -394,14 +394,13 @@ grammar_current_rule_symbol_append (symbol *sym, location loc)
|
||||
grammar_symbol_append (sym, loc);
|
||||
}
|
||||
|
||||
/* Attach an ACTION to the current rule. If needed, move the previous
|
||||
action as a mid-rule action. */
|
||||
/* Attach an ACTION to the current rule. */
|
||||
|
||||
void
|
||||
grammar_current_rule_action_append (const char *action, location loc)
|
||||
{
|
||||
if (current_rule->action)
|
||||
grammar_midrule_action ();
|
||||
/* There's no need to invoke grammar_midrule_action here, since the
|
||||
scanner already did it if necessary. */
|
||||
current_rule->action = action;
|
||||
current_rule->action_location = loc;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user