mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 21:03:04 +00:00
diagnostics: don't crash when declaring the error token as an nterm
Reported by wcventure. http://lists.gnu.org/archive/html/bug-bison/2019-03/msg00008.html * src/symtab.c (complain_class_redeclared): Don't print empty locations. There can only be empty locations for predefined symbols. And the only symbol that is lexically available is the error token. So this appears to be the only possible way to have an error involving an empty location. * tests/input.at (Symbol class redefinition): Check it.
This commit is contained in:
@@ -309,9 +309,12 @@ complain_class_redeclared (symbol *sym, symbol_class class, location second)
|
||||
class == token_sym
|
||||
? _("symbol %s redeclared as a token")
|
||||
: _("symbol %s redeclared as a nonterminal"), sym->tag);
|
||||
i += SUB_INDENT;
|
||||
complain_indent (&sym->location, complaint, &i,
|
||||
_("previous definition"));
|
||||
if (!location_empty (sym->location))
|
||||
{
|
||||
i += SUB_INDENT;
|
||||
complain_indent (&sym->location, complaint, &i,
|
||||
_("previous definition"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user