diff --git a/NEWS b/NEWS index 5f23fa79..b62141f1 100644 --- a/NEWS +++ b/NEWS @@ -19,10 +19,6 @@ GNU Bison NEWS ** Deprecated features - The directive %nterm, an historical heritage from an ancestor of Bison, - was never officially documented. Its use now triggers warnings. - Eventually, support will be removed. Use %type instead. - The use of the %error-verbose directive is deprecated in favor of "%define parse.error verbose" since Bison 3.0, but no warning was issued. diff --git a/src/parse-gram.y b/src/parse-gram.y index 865153b5..279b6166 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -202,7 +202,7 @@ %printer { fprintf (yyo, "%d", $$); } %type id id_colon string_as_id symbol symbol.prec -%printer { fprintf (yyo, "%s", $$->tag); } +%printer { fprintf (yyo, "%s", $$ ? $$->tag : ""); } %printer { fprintf (yyo, "%s:", $$->tag); } id_colon %type precedence_declarator diff --git a/src/scan-gram.l b/src/scan-gram.l index 61256a0d..d3662690 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -243,6 +243,7 @@ eqopt ([[:space:]]*=)? "%no-lines" return BISON_DIRECTIVE(NO_LINES); "%nonassoc" return PERCENT_NONASSOC; "%nondeterministic-parser" return BISON_DIRECTIVE(NONDETERMINISTIC_PARSER); + "%nterm" return BISON_DIRECTIVE(NTERM); "%output" return BISON_DIRECTIVE(OUTPUT); "%param" RETURN_PERCENT_PARAM(both); "%parse-param" RETURN_PERCENT_PARAM(parse); @@ -279,12 +280,6 @@ eqopt ([[:space:]]*=)? "%pure"[-_]"parser" DEPRECATED("%pure-parser"); "%token"[-_]"table" DEPRECATED("%token-table"); - "%nterm" { - /* Deprecated since Bison 3.3, but was a rather stealth feature. */ - deprecated_directive (loc, yytext, "%type"); - return PERCENT_NTERM; - } - "%"{id} { complain (loc, complaint, _("invalid directive: %s"), quote (yytext)); } diff --git a/src/symtab.c b/src/symtab.c index 0caf063a..7bc604b7 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -450,12 +450,11 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring) complain_class_redeclared (sym, class, loc); else { - s->class = class; - if (class == nterm_sym && s->class != nterm_sym) s->number = nvars++; else if (class == token_sym && s->number == NUMBER_UNDEFINED) s->number = ntokens++; + s->class = class; if (declaring) { diff --git a/tests/input.at b/tests/input.at index 44803ce5..2b0b5573 100644 --- a/tests/input.at +++ b/tests/input.at @@ -130,6 +130,28 @@ AT_BISON_CHECK([input.y], [1], [], AT_CLEANUP +## -------------------------- ## +## Yacc warnings on symbols. ## +## -------------------------- ## + +AT_SETUP([Yacc warnings on symbols]) + +AT_DATA([input.y], +[[%nterm exp +%token NUM 0x40 "number" +%% +exp: "number"; +]]) + +AT_BISON_CHECK([-fcaret -Wyacc input.y], [0], [], +[[input.y:1.1-6: warning: POSIX Yacc does not support %nterm [-Wyacc] + %nterm exp + ^^^^^^ +]]) + +AT_CLEANUP + + ## --------------------- ## ## Invalid %nterm uses. ## ## --------------------- ## @@ -149,36 +171,21 @@ fact: "number"; ]]) AT_BISON_CHECK([-fcaret input.y], [1], [], -[[input.y:1.1-6: warning: deprecated directive, use '%type' [-Wdeprecated] - %nterm expr "expression"; - ^^^^^^ -input.y:1.13-24: error: nonterminals cannot be given a string alias +[[input.y:1.13-24: error: nonterminals cannot be given a string alias %nterm expr "expression"; ^^^^^^^^^^^^ -input.y:2.1-6: warning: deprecated directive, use '%type' [-Wdeprecated] - %nterm term 123; - ^^^^^^ input.y:2.13-15: error: nonterminals cannot be given an explicit number %nterm term 123; ^^^ -input.y:3.1-6: warning: deprecated directive, use '%type' [-Wdeprecated] - %nterm fact 124 "factor"; - ^^^^^^ input.y:3.13-15: error: nonterminals cannot be given an explicit number %nterm fact 124 "factor"; ^^^ input.y:3.17-24: error: nonterminals cannot be given a string alias %nterm fact 124 "factor"; ^^^^^^^^ -input.y:4.1-6: warning: deprecated directive, use '%type' [-Wdeprecated] - %nterm '+' '*'; - ^^^^^^ input.y:4.8-10: error: character literals cannot be nonterminals %nterm '+' '*'; ^^^ -input.y:5.1-6: warning: deprecated directive, use '%type' [-Wdeprecated] - %nterm "number"; - ^^^^^^ input.y:5.8-15: error: syntax error, unexpected string, expecting char or identifier or %nterm "number"; ^^^^^^^^ @@ -499,10 +506,7 @@ BAR: ]]) AT_BISON_CHECK([-fcaret input.y], [1], [], -[[input.y:2.1-6: warning: deprecated directive, use '%type' [-Wdeprecated] - %nterm FOO BAR - ^^^^^^ -input.y:2.8-10: error: symbol FOO redeclared as a nonterminal +[[input.y:2.8-10: error: symbol FOO redeclared as a nonterminal %nterm FOO BAR ^^^ input.y:1.8-10: previous definition