mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 16:23:04 +00:00
diagnostics: yacc reserves %type to nonterminals
On
%token TOKEN1
%type <ival> TOKEN1 TOKEN2 't'
%token TOKEN2
%%
expr:
bison -Wyacc gives
input.y:2.15-20: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
2 | %type <ival> TOKEN1 TOKEN2 't'
| ^~~~~~
input.y:2.29-31: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
2 | %type <ival> TOKEN1 TOKEN2 't'
| ^~~
input.y:2.22-27: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
2 | %type <ival> TOKEN1 TOKEN2 't'
| ^~~~~~
The messages appear to be out of order, but they are emitted when the
error is found.
* src/symtab.h (symbol_class): Add pct_type_sym, used to denote
symbols appearing in %type.
* src/symtab.c (complain_pct_type_on_token): New.
(symbol_class_set): Check that %type is not applied to tokens.
(symbol_check_defined): pct_type_sym also means undefined.
* src/parse-gram.y (symbol_decl.1): Set the class to pct_type_sym.
* src/reader.c (grammar_current_rule_begin): pct_type_sym also means
undefined.
* tests/input.at (Yacc's %type): New.
This commit is contained in:
24
NEWS
24
NEWS
@@ -2,6 +2,30 @@ GNU Bison NEWS
|
||||
|
||||
* Noteworthy changes in release ?.? (????-??-??) [?]
|
||||
|
||||
** New Features
|
||||
|
||||
*** Better POSIX Yacc compatibility diagnostics
|
||||
|
||||
POSIX Yacc restricts %type to nonterminals. This is now diagnosed by
|
||||
-Wyacc.
|
||||
|
||||
%token TOKEN1
|
||||
%type <ival> TOKEN1 TOKEN2 't'
|
||||
%token TOKEN2
|
||||
%%
|
||||
expr:
|
||||
|
||||
gives, with -Wyacc
|
||||
|
||||
input.y:2.15-20: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||
| ^~~~~~
|
||||
input.y:2.29-31: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||
| ^~~
|
||||
input.y:2.22-27: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
|
||||
2 | %type <ival> TOKEN1 TOKEN2 't'
|
||||
| ^~~~~~
|
||||
|
||||
* Noteworthy changes in release 3.4.90 (2019-10-29) [beta]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user