mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 15:23:02 +00:00
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/lalr1.cc
data/yacc.c
src/parse-gram.c
src/parse-gram.h
This commit is contained in:
13
ChangeLog
13
ChangeLog
@@ -1,3 +1,16 @@
|
|||||||
|
2010-04-03 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
2010-04-05 Akim Demaille <demaille@gostai.com>
|
2010-04-05 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
remove useless include.
|
remove useless include.
|
||||||
|
|||||||
@@ -689,7 +689,7 @@ b4_percent_code_get[]dnl
|
|||||||
symbol_type yyla;]b4_locations_if([[
|
symbol_type yyla;]b4_locations_if([[
|
||||||
|
|
||||||
/// The locations where the error started and ended.
|
/// The locations where the error started and ended.
|
||||||
stack_symbol_type yyerror_range[2];]])[
|
stack_symbol_type yyerror_range[3];]])[
|
||||||
|
|
||||||
/// $$ and @@$.
|
/// $$ and @@$.
|
||||||
stack_symbol_type yylhs;
|
stack_symbol_type yylhs;
|
||||||
@@ -866,7 +866,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
|||||||
}
|
}
|
||||||
|
|
||||||
]b4_locations_if([[
|
]b4_locations_if([[
|
||||||
yyerror_range[0].location = yyla.location;]])[
|
yyerror_range[1].location = yyla.location;]])[
|
||||||
if (yyerrstatus_ == 3)
|
if (yyerrstatus_ == 3)
|
||||||
{
|
{
|
||||||
/* If just tried and failed to reuse lookahead token after an
|
/* If just tried and failed to reuse lookahead token after an
|
||||||
@@ -897,7 +897,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
|||||||
code. */
|
code. */
|
||||||
if (false)
|
if (false)
|
||||||
goto yyerrorlab;]b4_locations_if([[
|
goto yyerrorlab;]b4_locations_if([[
|
||||||
yyerror_range[0].location = yystack_[yylen - 1].location;]])b4_variant_if([[
|
yyerror_range[1].location = yystack_[yylen - 1].location;]])b4_variant_if([[
|
||||||
/* $$ was initialized before running the user action. */
|
/* $$ was initialized before running the user action. */
|
||||||
yy_destroy_ ("Error: discarding", yylhs);]])[
|
yy_destroy_ ("Error: discarding", yylhs);]])[
|
||||||
/* Do not reclaim the symbols of the rule which action triggered
|
/* Do not reclaim the symbols of the rule which action triggered
|
||||||
@@ -931,14 +931,14 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
|||||||
if (yystack_.size () == 1)
|
if (yystack_.size () == 1)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
]b4_locations_if([[
|
]b4_locations_if([[
|
||||||
yyerror_range[0].location = yystack_[0].location;]])[
|
yyerror_range[1].location = yystack_[0].location;]])[
|
||||||
yy_destroy_ ("Error: popping", yystack_[0]);
|
yy_destroy_ ("Error: popping", yystack_[0]);
|
||||||
yypop_ ();
|
yypop_ ();
|
||||||
YY_STACK_PRINT ();
|
YY_STACK_PRINT ();
|
||||||
}
|
}
|
||||||
]b4_locations_if([[
|
]b4_locations_if([[
|
||||||
yyerror_range[1].location = yyla.location;
|
yyerror_range[2].location = yyla.location;
|
||||||
YYLLOC_DEFAULT (error_token.location, (yyerror_range - 1), 2);]])[
|
YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);]])[
|
||||||
|
|
||||||
/* Shift the error token. */
|
/* Shift the error token. */
|
||||||
error_token.state = yyn;
|
error_token.state = yyn;
|
||||||
|
|||||||
12
data/yacc.c
12
data/yacc.c
@@ -205,7 +205,7 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
|
|||||||
YYLTYPE *yylsp;
|
YYLTYPE *yylsp;
|
||||||
|
|
||||||
/* The locations where the error started and ended. */
|
/* The locations where the error started and ended. */
|
||||||
YYLTYPE yyerror_range[2];]])[
|
YYLTYPE yyerror_range[3];]])[
|
||||||
|
|
||||||
YYSIZE_T yystacksize;]])
|
YYSIZE_T yystacksize;]])
|
||||||
|
|
||||||
@@ -1502,7 +1502,7 @@ yyerrlab:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_locations_if([[ yyerror_range[0] = yylloc;]])[
|
]b4_locations_if([[ yyerror_range[1] = yylloc;]])[
|
||||||
|
|
||||||
if (yyerrstatus == 3)
|
if (yyerrstatus == 3)
|
||||||
{
|
{
|
||||||
@@ -1539,7 +1539,7 @@ yyerrorlab:
|
|||||||
if (/*CONSTCOND*/ 0)
|
if (/*CONSTCOND*/ 0)
|
||||||
goto yyerrorlab;
|
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
|
]])[ /* Do not reclaim the symbols of the rule which action triggered
|
||||||
this YYERROR. */
|
this YYERROR. */
|
||||||
YYPOPSTACK (yylen);
|
YYPOPSTACK (yylen);
|
||||||
@@ -1573,7 +1573,7 @@ yyerrlab1:
|
|||||||
if (yyssp == yyss)
|
if (yyssp == yyss)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
|
|
||||||
]b4_locations_if([[ yyerror_range[0] = *yylsp;]])[
|
]b4_locations_if([[ yyerror_range[1] = *yylsp;]])[
|
||||||
yydestruct ("Error: popping",
|
yydestruct ("Error: popping",
|
||||||
yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
|
yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
|
||||||
YYPOPSTACK (1);
|
YYPOPSTACK (1);
|
||||||
@@ -1583,10 +1583,10 @@ yyerrlab1:
|
|||||||
|
|
||||||
*++yyvsp = yylval;
|
*++yyvsp = yylval;
|
||||||
]b4_locations_if([[
|
]b4_locations_if([[
|
||||||
yyerror_range[1] = yylloc;
|
yyerror_range[2] = yylloc;
|
||||||
/* Using YYLLOC is tempting, but would change the location of
|
/* Using YYLLOC is tempting, but would change the location of
|
||||||
the lookahead. YYLOC is available though. */
|
the lookahead. YYLOC is available though. */
|
||||||
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
|
YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
|
||||||
*++yylsp = yyloc;]])[
|
*++yylsp = yyloc;]])[
|
||||||
|
|
||||||
/* Shift the error token. */
|
/* Shift the error token. */
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* A Bison parser, made by GNU Bison 2.4.462-882b. */
|
/* A Bison parser, made by GNU Bison 2.4.483-4ad39-dirty. */
|
||||||
|
|
||||||
/* Implementation for Bison's Yacc-like parsers in C
|
/* Implementation for Bison's Yacc-like parsers in C
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
#define YYBISON 1
|
#define YYBISON 1
|
||||||
|
|
||||||
/* Bison version. */
|
/* Bison version. */
|
||||||
#define YYBISON_VERSION "2.4.462-882b"
|
#define YYBISON_VERSION "2.4.483-4ad39-dirty"
|
||||||
|
|
||||||
/* Skeleton name. */
|
/* Skeleton name. */
|
||||||
#define YYSKELETON_NAME "yacc.c"
|
#define YYSKELETON_NAME "yacc.c"
|
||||||
@@ -1688,7 +1688,7 @@ YYLTYPE yylloc;
|
|||||||
YYLTYPE *yylsp;
|
YYLTYPE *yylsp;
|
||||||
|
|
||||||
/* The locations where the error started and ended. */
|
/* The locations where the error started and ended. */
|
||||||
YYLTYPE yyerror_range[2];
|
YYLTYPE yyerror_range[3];
|
||||||
|
|
||||||
YYSIZE_T yystacksize;
|
YYSIZE_T yystacksize;
|
||||||
|
|
||||||
@@ -2865,7 +2865,7 @@ yyerrlab:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
yyerror_range[0] = yylloc;
|
yyerror_range[1] = yylloc;
|
||||||
|
|
||||||
if (yyerrstatus == 3)
|
if (yyerrstatus == 3)
|
||||||
{
|
{
|
||||||
@@ -2902,7 +2902,7 @@ yyerrorlab:
|
|||||||
if (/*CONSTCOND*/ 0)
|
if (/*CONSTCOND*/ 0)
|
||||||
goto yyerrorlab;
|
goto yyerrorlab;
|
||||||
|
|
||||||
yyerror_range[0] = yylsp[1-yylen];
|
yyerror_range[1] = yylsp[1-yylen];
|
||||||
/* Do not reclaim the symbols of the rule which action triggered
|
/* Do not reclaim the symbols of the rule which action triggered
|
||||||
this YYERROR. */
|
this YYERROR. */
|
||||||
YYPOPSTACK (yylen);
|
YYPOPSTACK (yylen);
|
||||||
@@ -2936,7 +2936,7 @@ yyerrlab1:
|
|||||||
if (yyssp == yyss)
|
if (yyssp == yyss)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
|
|
||||||
yyerror_range[0] = *yylsp;
|
yyerror_range[1] = *yylsp;
|
||||||
yydestruct ("Error: popping",
|
yydestruct ("Error: popping",
|
||||||
yystos[yystate], yyvsp, yylsp);
|
yystos[yystate], yyvsp, yylsp);
|
||||||
YYPOPSTACK (1);
|
YYPOPSTACK (1);
|
||||||
@@ -2946,10 +2946,10 @@ yyerrlab1:
|
|||||||
|
|
||||||
*++yyvsp = yylval;
|
*++yyvsp = yylval;
|
||||||
|
|
||||||
yyerror_range[1] = yylloc;
|
yyerror_range[2] = yylloc;
|
||||||
/* Using YYLLOC is tempting, but would change the location of
|
/* Using YYLLOC is tempting, but would change the location of
|
||||||
the lookahead. YYLOC is available though. */
|
the lookahead. YYLOC is available though. */
|
||||||
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
|
YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
|
||||||
*++yylsp = yyloc;
|
*++yylsp = yyloc;
|
||||||
|
|
||||||
/* Shift the error token. */
|
/* Shift the error token. */
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* A Bison parser, made by GNU Bison 2.4.462-882b. */
|
/* A Bison parser, made by GNU Bison 2.4.483-4ad39-dirty. */
|
||||||
|
|
||||||
/* Interface for Bison's Yacc-like parsers in C
|
/* Interface for Bison's Yacc-like parsers in C
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user