From d3a86f7b20bd3a6756f2382fad12beafba0443e7 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 6 Sep 2019 07:21:59 +0200 Subject: [PATCH] yacc.c: beware of GCC's -Wmaybe-uninitialized Test 400 (calc.at:773: testing Calculator api.push-pull=both api.pure=full parse.error=verbose %debug %locations %defines api.prefix={calc} %verbose %yacc) fails on the CI with GCC 8 on Bionic: 400. calc.at:773: testing Calculator api.push-pull=both api.pure=full parse.error=verbose %debug %locations %defines api.prefix={calc} %verbose %yacc ... ../../tests/calc.at:773: bison --color=no -fno-caret -Wno-deprecated -o calc.c calc.y ../../tests/calc.at:773: $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c calc-lex.c calc-main.c $LIBS stderr: calc.y: In function 'int calcpush_parse(calcpstate*, int, const CALCSTYPE*, CALCLTYPE*)': calc.y:26:20: error: 'yylval.CALCSTYPE::ival' may be used uninitialized in this function [-Werror=maybe-uninitialized] %printer { fprintf (yyo, "%d", $$); } ; ^ calc.c:1272:9: note: 'yylval.CALCSTYPE::ival' was declared here YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); ^~~~~~ cc1plus: all warnings being treated as errors stdout: ../../tests/calc.at:773: exit code was 1, expected 0 400. calc.at:773: 400. Calculator api.push-pull=both api.pure=full parse.error=verbose %debug %locations %defines api.prefix={calc} %verbose %yacc (calc.at:773): FAILED (calc.at:773) * data/skeletons/c.m4 (yy_symbol_value_print): Disable the warning locally. --- data/skeletons/c.m4 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4 index fcf58a84..27aa2939 100644 --- a/data/skeletons/c.m4 +++ b/data/skeletons/c.m4 @@ -545,7 +545,9 @@ m4_if(b4_skeleton, ["yacc.c"], # endif ]])dnl b4_percent_code_get([[pre-printer]])dnl + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN b4_symbol_actions([printer]) + YY_IGNORE_MAYBE_UNINITIALIZED_END b4_percent_code_get([[post-printer]])dnl [}