bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 5/6] yacc.c: beware of GCC's -Wmaybe-uninitialized


From: Akim Demaille
Subject: [PATCH 5/6] yacc.c: beware of GCC's -Wmaybe-uninitialized
Date: Fri, 6 Sep 2019 22:27:52 +0200

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", $$); } <ival>;
                        ^
    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
 [}
 
-- 
2.23.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]