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

@@ -553,7 +553,7 @@ do { \
/// Location of the lookahead.
location_type yylloc;
/// The locations where the error started and ended.
location_type yyerror_range[2];
location_type yyerror_range[3];
/// $$.
semantic_type yyval;
@@ -723,7 +723,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
error (yylloc, yysyntax_error_ (yystate, yytoken));
}
yyerror_range[0] = yylloc;
yyerror_range[1] = yylloc;
if (yyerrstatus_ == 3)
{
/* If just tried and failed to reuse lookahead token after an
@@ -758,7 +758,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
if (false)
goto yyerrorlab;
yyerror_range[0] = yylocation_stack_[yylen - 1];
yyerror_range[1] = yylocation_stack_[yylen - 1];
/* Do not reclaim the symbols of the rule which action triggered
this YYERROR. */
yypop_ (yylen);
@@ -790,7 +790,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
if (yystate_stack_.height () == 1)
YYABORT;
yyerror_range[0] = yylocation_stack_[0];
yyerror_range[1] = yylocation_stack_[0];
yydestruct_ ("Error: popping",
yystos_[yystate],
&yysemantic_stack_[0], &yylocation_stack_[0]);
@@ -799,10 +799,10 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
YY_STACK_PRINT ();
}
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);
yysemantic_stack_.push (yylval);
yylocation_stack_.push (yyloc);