X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/9ce27ab013185d1c17c78e0d57ff637319cb1e29..0d40b36417759153678ed0ad125bc912884f602d:/src/reduce.c?ds=sidebyside diff --git a/src/reduce.c b/src/reduce.c index de046ddb..a61ae4c6 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -1,6 +1,6 @@ /* Grammar reduction for Bison. - Copyright (C) 1988-1989, 2000-2003, 2005-2012 Free Software + Copyright (C) 1988-1989, 2000-2003, 2005-2015 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -49,7 +49,7 @@ static bitset P; static bitset V; /* Set of symbols used to define rule precedence (so they are - `useless', but no warning should be issued). */ + 'useless', but no warning should be issued). */ static bitset V1; static rule_number nuseful_productions; @@ -285,13 +285,12 @@ reduce_grammar_tables (void) static void nonterminals_reduce (void) { - symbol_number i, n; - /* Map the nonterminals to their new index: useful first, useless afterwards. Kept for later report. */ symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap); - n = ntokens; + symbol_number n = ntokens; + symbol_number i; for (i = ntokens; i < nsyms; i++) if (bitset_test (V, i)) nontermmap[i - ntokens] = n++; @@ -299,8 +298,10 @@ nonterminals_reduce (void) if (!bitset_test (V, i)) { nontermmap[i - ntokens] = n++; - warn_at (symbols[i]->location, _("nonterminal useless in grammar: %s"), - symbols[i]->tag); + if (symbols[i]->status != used) + complain (&symbols[i]->location, Wother, + _("nonterminal useless in grammar: %s"), + symbols[i]->tag); } @@ -382,15 +383,15 @@ static void reduce_print (void) { if (nuseless_nonterminals > 0) - warn (ngettext ("%d nonterminal useless in grammar", - "%d nonterminals useless in grammar", - nuseless_nonterminals), - nuseless_nonterminals); + complain (NULL, Wother, ngettext ("%d nonterminal useless in grammar", + "%d nonterminals useless in grammar", + nuseless_nonterminals), + nuseless_nonterminals); if (nuseless_productions > 0) - warn (ngettext ("%d rule useless in grammar", - "%d rules useless in grammar", - nuseless_productions), - nuseless_productions); + complain (NULL, Wother, ngettext ("%d rule useless in grammar", + "%d rules useless in grammar", + nuseless_productions), + nuseless_productions); } void @@ -415,7 +416,7 @@ reduce_grammar (void) reduce_print (); if (!bitset_test (N, accept->number - ntokens)) - fatal_at (startsymbol_location, + complain (&startsymbol_location, fatal, _("start symbol %s does not derive any sentence"), startsymbol->tag); @@ -431,8 +432,8 @@ reduce_grammar (void) { grammar_dump (stderr, "Reduced Grammar"); - fprintf (stderr, "reduced %s defines %d terminals, %d nonterminals\ -, and %d productions.\n", + fprintf (stderr, "reduced %s defines %d terminals, %d nonterminals" + ", and %d productions.\n", grammar_file, ntokens, nvars, nrules); } }