portability: fix pointer arithmetic to conform to C standard.

Reported by Tys Lefering at
<http://lists.gnu.org/archive/html/bug-bison/2010-03/msg00035.html>.
This fix is already implemented in glr.c and does not apply to
lalr1.java.
* data/lalr1.cc (yy::parser::parse): Increase size of
yyerror_range and adjust subscripting so you don't have to
subtract one from the beginning of the array.
* data/yacc.c (b4_declare_parser_state_variables,
yyparse, yypush_parse): Likewise.
(cherry picked from commit 48f4100a82)

Conflicts:

	data/yacc.c
	src/parse-gram.c
	src/parse-gram.h
This commit is contained in:
Joel E. Denny
2010-04-03 14:58:22 -04:00
parent 8a8b33e8d2
commit a005dbcbe3
5 changed files with 34 additions and 21 deletions

View File

@@ -203,7 +203,7 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
YYLTYPE *yylsp;
/* The locations where the error started and ended. */
YYLTYPE yyerror_range[2];]])[
YYLTYPE yyerror_range[3];]])[
YYSIZE_T yystacksize;]])
@@ -1568,7 +1568,7 @@ yyerrlab:
#endif
}
]b4_locations_if([[ yyerror_range[0] = yylloc;]])[
]b4_locations_if([[ yyerror_range[1] = yylloc;]])[
if (yyerrstatus == 3)
{
@@ -1605,7 +1605,7 @@ yyerrorlab:
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
]b4_locations_if([[ yyerror_range[0] = yylsp[1-yylen];
]b4_locations_if([[ yyerror_range[1] = yylsp[1-yylen];
]])[ /* Do not reclaim the symbols of the rule which action triggered
this YYERROR. */
YYPOPSTACK (yylen);
@@ -1639,7 +1639,7 @@ yyerrlab1:
if (yyssp == yyss)
YYABORT;
]b4_locations_if([[ yyerror_range[0] = *yylsp;]])[
]b4_locations_if([[ yyerror_range[1] = *yylsp;]])[
yydestruct ("Error: popping",
yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
YYPOPSTACK (1);
@@ -1649,10 +1649,10 @@ yyerrlab1:
*++yyvsp = yylval;
]b4_locations_if([[
yyerror_range[1] = yylloc;
yyerror_range[2] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
the lookahead. YYLOC is available though. */
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
*++yylsp = yyloc;]])[
/* Shift the error token. */