bison-2.7 produces compile-error (in transformed hackt-parse-real.cc)
Closed this issue · 2 comments
fangism commented
This excerpt in the generated hackt-parse.cc is new (to me) and produces a compiler error:
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
_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 YY_INITIAL_VALUE(Value) = Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
error:
make[2]: Entering directory `/usr/local/google/home/fangism/Downloads/src/hackt/build/src'
/bin/sh ../libtool --tag=CXX --mode=compile clang++-3.5 -DHAVE_CONFIG_H -I. -I../../src -I../../src -pipe -ansi -pedantic-errors -Wold-style-cast -Woverloaded-virtual -W -Wextra -Wall -Wundef -Wshadow -Wno-unused-parameter -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion -Werror -Wno-unused -Wno-old-style-cast -Wno-shadow -Wno-error=sign-compare -Wno-error=sign-conversion -Wno-error=unused-function -Wno-error=conversion -Qunused-arguments -MT parser/libhacktparsers_la-hackt-parse-real.lo -MD -MP -MF parser/.deps/libhacktparsers_la-hackt-parse-real.Tpo -c -o parser/libhacktparsers_la-hackt-parse-real.lo `test -f 'parser/hackt-parse-real.cc' || echo '../../src/'`parser/hackt-parse-real.cc
libtool: compile: clang++-3.5 -DHAVE_CONFIG_H -I. -I../../src -I../../src -pipe -ansi -pedantic-errors -Wold-style-cast -Woverloaded-virtual -W -Wextra -Wall -Wundef -Wshadow -Wno-unused-parameter -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion -Werror -Wno-unused -Wno-old-style-cast -Wno-shadow -Wno-error=sign-compare -Wno-error=sign-conversion -Wno-error=unused-function -Wno-error=conversion -Qunused-arguments -MT parser/libhacktparsers_la-hackt-parse-real.lo -MD -MP -MF parser/.deps/libhacktparsers_la-hackt-parse-real.Tpo -c parser/hackt-parse-real.cc -fPIC -DPIC -o parser/.libs/libhacktparsers_la-hackt-parse-real.o
parser/hackt-parse.cc:2827:9: error: redefinition of 'hackt_lval' with a different type: 'YYSTYPE' vs 'YYSTYPE &'
YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
^
./parser/hackt-prefix.h:40:17: note: expanded from macro 'yylval'
#define yylval hackt_lval
^
parser/hackt-parse.cc:2782:16: note: previous definition is here
yyparse (void *YYPARSE_PARAM)
^
../../src/parser/hackt-parse-options.h:69:39: note: expanded from macro 'YYPARSE_PARAM'
#define YYPARSE_PARAM null, YYSTYPE& hackt_lval, flex::lexer_state& _lexer_state
^
parser/hackt-parse.cc:2897:12: warning: implicit conversion loses integer precision: 'int' to 'yytype_int16' (aka 'short') [-Wconversion]
*yyssp = yystate;
~ ^~~~~~~
./parser/hackt-prefix.h:12:18: note: expanded from macro 'yystate'
#define yystate hackt_state
^~~~~~~~~~~
parser/hackt-parse.cc:2902:38: warning: implicit conversion changes signedness: 'long' to 'unsigned long' [-Wsign-conversion]
YYSIZE_T yysize = yyssp - yyss + 1;
~~~~~~ ~~~~~~~~~~~~~^~~
2 warnings and 1 error generated.
make[2]: *** [parser/libhacktparsers_la-hackt-parse-real.lo] Error 1
This is generated by bison-2.7.
fangism commented
diagnosis:
yylval (a.k.a. hackt_lval) is declared as a function-local static variable with initial value, but we override the params of yyparse to pass it in by reference. Solution is to suppress that declaration with initial value, as it is not needed.
fangism commented
Simple fix is to update a grep -v "YYSTYPE yylval;" to cover initial values.
Patch is pending.