mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
yacc.c: initialize yylval in pure-parser mode
See http://lists.gnu.org/archive/html/bison-patches/2012-08/msg00024.html (spreading over September and October). * data/yacc.c (YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN) (YY_IGNORE_MAYBE_UNINITIALIZED_END, YYLVAL_INITIALIZE): New macros. Use them to suppress an unwanted GCC diagnostic.
This commit is contained in:
committed by
Akim Demaille
parent
39845e8e40
commit
fa5303b8ff
29
data/yacc.c
29
data/yacc.c
@@ -170,6 +170,28 @@ m4_define([b4_declare_scanner_communication_variables], [[
|
|||||||
/* The lookahead symbol. */
|
/* The lookahead symbol. */
|
||||||
int yychar;
|
int yychar;
|
||||||
|
|
||||||
|
]b4_pure_if([[
|
||||||
|
#if defined __GNUC__ && (4 < __GNUC__ + (6 <= __GNUC_MINOR__))
|
||||||
|
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
||||||
|
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||||
|
_Pragma ("GCC diagnostic push") \
|
||||||
|
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
|
||||||
|
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
|
||||||
|
_Pragma ("GCC diagnostic pop")
|
||||||
|
#else
|
||||||
|
/* Default value used for initialization, for pacifying older GCCs
|
||||||
|
or non-GCC compilers. */
|
||||||
|
static YYSTYPE yyval_default;
|
||||||
|
# define YYLVAL_INITIALIZE() (yylval = yyval_default)
|
||||||
|
#endif]])[
|
||||||
|
#ifndef YYLVAL_INITIALIZE
|
||||||
|
# define YYLVAL_INITIALIZE()
|
||||||
|
#endif
|
||||||
|
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||||
|
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||||
|
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The semantic value of the lookahead symbol. */
|
/* The semantic value of the lookahead symbol. */
|
||||||
YYSTYPE yylval;]b4_locations_if([[
|
YYSTYPE yylval;]b4_locations_if([[
|
||||||
|
|
||||||
@@ -1563,8 +1585,9 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
|
|||||||
The wasted elements are never initialized. */
|
The wasted elements are never initialized. */
|
||||||
yyssp = yyss;
|
yyssp = yyss;
|
||||||
yyvsp = yyvs;]b4_locations_if([[
|
yyvsp = yyvs;]b4_locations_if([[
|
||||||
yylsp = yyls;
|
yylsp = yyls;]])[
|
||||||
|
|
||||||
|
YYLVAL_INITIALIZE ();]b4_locations_if([[
|
||||||
#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||||
/* Initialize the default location before parsing starts. */
|
/* Initialize the default location before parsing starts. */
|
||||||
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
|
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
|
||||||
@@ -1750,7 +1773,9 @@ yyread_pushed_token:]])[
|
|||||||
YY_LAC_DISCARD ("shift");]])[
|
YY_LAC_DISCARD ("shift");]])[
|
||||||
|
|
||||||
yystate = yyn;
|
yystate = yyn;
|
||||||
|
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||||
*++yyvsp = yylval;
|
*++yyvsp = yylval;
|
||||||
|
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||||
]b4_locations_if([ *++yylsp = yylloc;])[
|
]b4_locations_if([ *++yylsp = yylloc;])[
|
||||||
goto yynewstate;
|
goto yynewstate;
|
||||||
|
|
||||||
@@ -1970,7 +1995,9 @@ yyerrlab1:
|
|||||||
current lookahead token, the shift below will for sure. */
|
current lookahead token, the shift below will for sure. */
|
||||||
YY_LAC_DISCARD ("error recovery");]])[
|
YY_LAC_DISCARD ("error recovery");]])[
|
||||||
|
|
||||||
|
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||||
*++yyvsp = yylval;
|
*++yyvsp = yylval;
|
||||||
|
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||||
]b4_locations_if([[
|
]b4_locations_if([[
|
||||||
yyerror_range[2] = 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
|
||||||
|
|||||||
Reference in New Issue
Block a user