mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 23:03: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:
@@ -510,11 +510,11 @@ static const yytype_int16 yyrline[] =
|
||||
453, 457, 467, 468, 469, 470, 474, 475, 480, 481,
|
||||
485, 486, 490, 491, 492, 505, 514, 518, 522, 530,
|
||||
531, 535, 548, 549, 561, 565, 569, 577, 579, 584,
|
||||
591, 601, 605, 609, 617, 618, 626, 627, 633, 634,
|
||||
635, 642, 642, 650, 651, 652, 657, 660, 662, 664,
|
||||
666, 668, 670, 672, 674, 676, 681, 682, 691, 715,
|
||||
716, 717, 718, 730, 732, 759, 764, 765, 770, 779,
|
||||
780, 784, 785
|
||||
591, 601, 605, 609, 617, 622, 634, 635, 641, 642,
|
||||
643, 650, 650, 658, 659, 660, 665, 668, 670, 672,
|
||||
674, 676, 678, 680, 682, 684, 689, 690, 699, 723,
|
||||
724, 725, 726, 738, 740, 767, 772, 773, 778, 787,
|
||||
788, 792, 793
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -2410,11 +2410,17 @@ yyreduce:
|
||||
break;
|
||||
|
||||
case 84:
|
||||
{ (yyval.yytype_86) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); }
|
||||
{
|
||||
symbol_class_set ((yyvsp[0].symbol), pct_type_sym, (yylsp[0]), false);
|
||||
(yyval.yytype_86) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]));
|
||||
}
|
||||
break;
|
||||
|
||||
case 85:
|
||||
{ (yyval.yytype_86) = symbol_list_append ((yyvsp[-1].yytype_86), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); }
|
||||
{
|
||||
symbol_class_set ((yyvsp[0].symbol), pct_type_sym, (yylsp[0]), false);
|
||||
(yyval.yytype_86) = symbol_list_append ((yyvsp[-1].yytype_86), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])));
|
||||
}
|
||||
break;
|
||||
|
||||
case 90:
|
||||
|
||||
Reference in New Issue
Block a user