Don't apply the default %destructor/%printer to an unreferenced midrule

value.  Mentioned at
<http://lists.gnu.org/archive/html/bison-patches/2006-09/msg00104.html>.
* src/symtab.c (dummy_symbol_get): Name all dummy symbols initially
like $@n instead of just @n so that the default %destructor/%printer
logic doesn't see them as user-defined symbols.
(symbol_is_dummy): Check for both forms of the name.
* src/reader.c (packgram): Remove the `$' from each midrule symbol
name for which the midrule value is referenced in any action.
* tests/actions.at (Default %printer and %destructor for mid-rule
values): New test.
* tests/regression.at (Rule Line Numbers, Web2c Report): Update output
for change to dummy symbol names.
This commit is contained in:
Joel E. Denny
2006-10-21 04:52:43 +00:00
parent 519d000408
commit f91b162944
5 changed files with 165 additions and 34 deletions

View File

@@ -769,7 +769,7 @@ dummy_symbol_get (location loc)
symbol *sym;
sprintf (buf, "@%d", ++dummy_count);
sprintf (buf, "$@%d", ++dummy_count);
sym = symbol_get (buf, loc);
sym->class = nterm_sym;
sym->number = nvars++;
@@ -779,7 +779,7 @@ dummy_symbol_get (location loc)
bool
symbol_is_dummy (const symbol *sym)
{
return sym->tag[0] == '@';
return sym->tag[0] == '@' || (sym->tag[0] == '$' && sym->tag[1] == '@');
}
/*-------------------.