mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 01:03:04 +00:00
yacc.c: initialize yylval and yylloc.
When generating a pure push parser, the initialization of yylval and yylloc may not be visible to the compiler. With warnings enabled, GCC 4.3.6, 4.4.7, 4.5.4, and 4.6.3 report uninitialized uses of yylval/yylloc. Using local pragmas to disable these warnings is not supported before 4.6, and 4.6 does not support it properly. So initialize yylval and yylloc at their definition. Reported by Peter Simons. See http://lists.gnu.org/archive/html/bison-patches/2012-10/msg00133.html * data/c.m4 (b4_yyloc_default_define): New. * data/yacc.c: Use it when locations are requested. (YYLVAL_INITIALIZE): Replace by... (YY_INITIAL_VALUE): this. (yyparse): Initialize yylloc and yylval. Therefore, remove the initialization of yylloc's field. * data/glr.c: Likewise.
This commit is contained in:
16
data/c.m4
16
data/c.m4
@@ -643,3 +643,19 @@ m4_define([b4_yylloc_default_define],
|
||||
while (YYID (0))
|
||||
#endif
|
||||
]])
|
||||
|
||||
# b4_yyloc_default_define
|
||||
# ------------------------
|
||||
# Define yyloc_default, which can be used to initialize location
|
||||
# variables.
|
||||
m4_define([b4_yyloc_default_define],
|
||||
[[static YYLTYPE yyloc_default
|
||||
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||
= { ]m4_join([, ],
|
||||
m4_defn([b4_location_initial_line]),
|
||||
m4_defn([b4_location_initial_column]),
|
||||
m4_defn([b4_location_initial_line]),
|
||||
m4_defn([b4_location_initial_column]))[ }
|
||||
# endif
|
||||
;]dnl
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user