diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2019-03-30 09:37:22 +0100 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2019-03-30 16:37:47 +0100 |
commit | a8558bc5a6db4f9b7f89edb73a019fd70cc9301f (patch) | |
tree | 97e40f1317fad4af42970cc2bfbd1793cfe98ac8 /tests | |
parent | bbf37f2534a8e5a6b4e28047f0a10903e6dc73f9 (diff) | |
download | bison-a8558bc5a6db4f9b7f89edb73a019fd70cc9301f.tar.gz |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/input.at | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/input.at b/tests/input.at index 312aa5a9..70c0cecc 100644 --- a/tests/input.at +++ b/tests/input.at @@ -625,6 +625,7 @@ AT_DATA([[input.y]], [[%token FOO %nterm FOO BAR %token BAR +%nterm error // The token error cannot be redefined as an nterm. %% FOO: BAR BAR: @@ -643,7 +644,10 @@ input.y:3.8-10: error: symbol BAR redeclared as a token input.y:2.12-14: previous definition %nterm FOO BAR ^~~ -input.y:5.1-3: error: rule given for FOO, which is a token +input.y:4.8-12: error: symbol error redeclared as a nonterminal + %nterm error // The token error cannot be redefined as an nterm. + ^~~~~ +input.y:6.1-3: error: rule given for FOO, which is a token FOO: BAR ^~~ ]]) |