mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 21:33:04 +00:00
When a literal string is used to define two different tokens,
`bison -v' segfaults. Reported by Piotr Gackiewicz, and fixed by Neil Booth. * tests/regression.m4: New file. Include the core of the sample provided by Piotr Gackiewicz. * src/reader.c (parse_token_decl): Diagnose bad cases, and proceed properly.
This commit is contained in:
28
src/reader.c
28
src/reader.c
@@ -372,17 +372,25 @@ parse_token_decl (symbol_class what_is, symbol_class what_is_not)
|
||||
}
|
||||
else if (token == IDENTIFIER && *symval->tag == '\"' && symbol)
|
||||
{
|
||||
if (symval->alias)
|
||||
warn (_("symbol `%s' used more than once as a literal string"),
|
||||
symval->tag);
|
||||
else if (symbol->alias)
|
||||
warn (_("symbol `%s' given more than one literal string"),
|
||||
symbol->tag);
|
||||
else
|
||||
{
|
||||
symval->class = token_sym;
|
||||
symval->type_name = typename;
|
||||
symval->user_token_number = symbol->user_token_number;
|
||||
symbol->user_token_number = SALIAS;
|
||||
symval->alias = symbol;
|
||||
symbol->alias = symval;
|
||||
/* symbol and symval combined are only one symbol */
|
||||
nsyms--;
|
||||
}
|
||||
translations = 1;
|
||||
symval->class = token_sym;
|
||||
symval->type_name = typename;
|
||||
symval->user_token_number = symbol->user_token_number;
|
||||
symbol->user_token_number = SALIAS;
|
||||
|
||||
symval->alias = symbol;
|
||||
symbol->alias = symval;
|
||||
symbol = NULL;
|
||||
|
||||
nsyms--; /* symbol and symval combined are only one symbol */
|
||||
symbol = NULL;
|
||||
}
|
||||
else if (token == IDENTIFIER)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user