mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 21:03:04 +00:00
* data/glr.c (yyreportSyntaxError): Fix off-by-one error in
checking against YYLAST that caused the parser to miss a potential alternative in its diagnostic. Problem reported by Maria Jose Moron Fernandez in <http://lists.gnu.org/archive/html/bug-bison/2006-05/msg00024.html>. * data/lalr1.cc (yysyntax_error_): Likewise. * data/yacc.c (yysyntax_error): Likewise. * tests/regression.at (_AT_DATA_DANCER_Y): Use static array for tokens, in case we run into an older C compiler. (_AT_DATA_EXPECT2_Y, AT_CHECK_EXPECT2): New macros. Use them to check for the off-by-one error fixed above.
This commit is contained in:
@@ -2077,7 +2077,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
#if YYERROR_VERBOSE
|
||||
int yyn;
|
||||
yyn = yypact[yystackp->yytops.yystates[0]->yylrState];
|
||||
if (YYPACT_NINF < yyn && yyn < YYLAST)
|
||||
if (YYPACT_NINF < yyn && yyn <= YYLAST)
|
||||
{
|
||||
yySymbol yytoken = YYTRANSLATE (yychar);
|
||||
size_t yysize0 = yytnamerr (NULL, yytokenName (yytoken));
|
||||
@@ -2104,7 +2104,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
int yychecklim = YYLAST - yyn;
|
||||
int yychecklim = YYLAST - yyn + 1;
|
||||
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
||||
int yycount = 1;
|
||||
|
||||
|
||||
@@ -838,14 +838,14 @@ b4_error_verbose_if([, int tok])[)
|
||||
YYUSE (yystate);
|
||||
#if YYERROR_VERBOSE
|
||||
int yyn = yypact_[yystate];
|
||||
if (yypact_ninf_ < yyn && yyn < yylast_)
|
||||
if (yypact_ninf_ < yyn && yyn <= yylast_)
|
||||
{
|
||||
/* Start YYX at -YYN if negative to avoid negative indexes in
|
||||
YYCHECK. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
int yychecklim = yylast_ - yyn;
|
||||
int yychecklim = yylast_ - yyn + 1;
|
||||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||
int count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
|
||||
@@ -847,7 +847,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
|
||||
{
|
||||
int yyn = yypact[yystate];
|
||||
|
||||
if (! (YYPACT_NINF < yyn && yyn < YYLAST))
|
||||
if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
@@ -885,7 +885,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
int yychecklim = YYLAST - yyn;
|
||||
int yychecklim = YYLAST - yyn + 1;
|
||||
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
||||
int yycount = 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user