From: Akim Demaille Date: Mon, 29 Jul 2002 17:28:56 +0000 (+0000) Subject: * src/reduce.c (reduce_grammar): When the language is empty, X-Git-Tag: BISON-1_49b~66 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/1bfb97dba532a32dbeffddd378955055b9277303 * src/reduce.c (reduce_grammar): When the language is empty, complain about the start symbol, not the axiom. Use its location. * tests/reduce.at (Empty Language): New. --- diff --git a/ChangeLog b/ChangeLog index da80bdc4..5b9c35df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-07-29 Akim Demaille + + * src/reduce.c (reduce_grammar): When the language is empty, + complain about the start symbol, not the axiom. + Use its location. + * tests/reduce.at (Empty Language): New. + 2002-07-26 Akim Demaille * src/reader.h, src/reader.c (gram_error): ... can't get diff --git a/src/reduce.c b/src/reduce.c index 154e63bf..aadf3f88 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -439,8 +439,9 @@ reduce_grammar (void) reduce_print (); if (!bitset_test (N, axiom->number - ntokens)) - fatal (_("Start symbol %s does not derive any sentence"), - symbols[axiom->number]->tag); + fatal_at (startsymbol_location, + _("start symbol %s does not derive any sentence"), + startsymbol->tag); /* First reduce the nonterminals, as they renumber themselves in the whole grammar. If you change the order, nonterms would be diff --git a/tests/reduce.at b/tests/reduce.at index 7dc939ed..4c8da723 100644 --- a/tests/reduce.at +++ b/tests/reduce.at @@ -332,3 +332,24 @@ Useless rules ]]) AT_CLEANUP + + + +## ---------------- ## +## Empty Language. ## +## ---------------- ## + +AT_SETUP([Empty Language]) + +AT_DATA([[input.y]], +[[%output="input.c" +%% +exp: exp; +]]) + +AT_CHECK([[bison input.y]], 1, [], +[[input.y: warning: 2 useless nonterminals and 2 useless rules +input.y:3.1-3: fatal error: start symbol exp does not derive any sentence +]]) + +AT_CLEANUP