mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-13 06:13:02 +00:00
multistart: check duplicates
* src/symlist.h, src/symlist.c (symbol_list_find_symbol) (symbol_list_last): New. (symbol_list_append): Use symbol_list_last. * src/reader.c (grammar_start_symbols_add): Check and discard duplicates. * tests/input.at (Duplicate %start symbol): New. * tests/reduce.at (Bad start symbols): Add the multistart keyword.
This commit is contained in:
@@ -1814,6 +1814,75 @@ AT_BISON_CHECK([-o input.c input.y])
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## ------------------------- ##
|
||||
## Duplicate %start symbol. ##
|
||||
## ------------------------- ##
|
||||
|
||||
AT_SETUP([Duplicate %start symbol])
|
||||
|
||||
AT_KEYWORDS([multistart])
|
||||
|
||||
AT_DATA([input.y],
|
||||
[[%start exp exp exp
|
||||
%%
|
||||
exp: %empty;
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([-fcaret input.y], [0], [],
|
||||
[[input.y:1.12-14: warning: duplicate directive [-Wother]
|
||||
1 | %start exp exp exp
|
||||
| ^~~
|
||||
input.y:1.8-10: note: previous declaration
|
||||
1 | %start exp exp exp
|
||||
| ^~~
|
||||
input.y:1.16-18: warning: duplicate directive [-Wother]
|
||||
1 | %start exp exp exp
|
||||
| ^~~
|
||||
input.y:1.8-10: note: previous declaration
|
||||
1 | %start exp exp exp
|
||||
| ^~~
|
||||
input.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
|
||||
]])
|
||||
|
||||
AT_DATA([input.y],
|
||||
[[%start exp foo exp
|
||||
%%
|
||||
exp: foo;
|
||||
foo: %empty;
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([-fcaret input.y], [0], [],
|
||||
[[input.y:1.16-18: warning: duplicate directive [-Wother]
|
||||
1 | %start exp foo exp
|
||||
| ^~~
|
||||
input.y:1.8-10: note: previous declaration
|
||||
1 | %start exp foo exp
|
||||
| ^~~
|
||||
input.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
|
||||
]])
|
||||
|
||||
AT_DATA([input.y],
|
||||
[[%start exp foo
|
||||
%start exp
|
||||
%%
|
||||
exp: foo;
|
||||
foo: %empty;
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([-fcaret input.y], [0], [],
|
||||
[[input.y:2.8-10: warning: duplicate directive [-Wother]
|
||||
2 | %start exp
|
||||
| ^~~
|
||||
input.y:1.8-10: note: previous declaration
|
||||
1 | %start exp foo
|
||||
| ^~~
|
||||
input.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
|
||||
]])
|
||||
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## --------------------- ##
|
||||
## %prec takes a token. ##
|
||||
## --------------------- ##
|
||||
|
||||
@@ -452,7 +452,7 @@ AT_CLEANUP
|
||||
AT_SETUP([Bad start symbols])
|
||||
|
||||
m4_pushdef([AT_TEST],
|
||||
[
|
||||
[AT_BISON_OPTION_PUSHDEFS([$1])
|
||||
AT_DATA([[input.y]],
|
||||
[%%
|
||||
$1
|
||||
@@ -461,6 +461,7 @@ $1
|
||||
AT_BISON_CHECK([[input.y]], 1, [],
|
||||
[$2
|
||||
])
|
||||
AT_BISON_OPTION_POPDEFS([$1])
|
||||
])
|
||||
|
||||
AT_TEST(
|
||||
|
||||
Reference in New Issue
Block a user