bug-bison
[Top][All Lists]
Advanced

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

Re: bison-2.6.4-generated parser triggers pragma warnings in GCC 4.6.3


From: Akim Demaille
Subject: Re: bison-2.6.4-generated parser triggers pragma warnings in GCC 4.6.3
Date: Fri, 26 Oct 2012 09:56:45 +0200

FWIW, after having applied trivial fixes
(http://lists.gnu.org/archive/html/bison-patches/2012-10/msg00133.html)
and the appended patch (not pushed), here at the failures I have:

4.3: 187, 328
4.4: 187, 328, 335
4.5: 274, 328, 335
4.6: 274, 328

No failure with 4.2, 4.7, 4.8, Apple Clang, and Clang 3.2.

> 187. calc.at:644: testing Calculator %define api.push-pull both %define 
> api.pure %locations ...
> ../../../tests/calc.at:644: bison -o calc.c calc.y
> ../../../tests/calc.at:644: $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c 
> $LIBS
> stderr:
> cc1: warnings being treated as errors
> calc.c: In function 'yypush_parse':
> calc.c:1369: error: 'yylloc.last_line' may be used uninitialized in this 
> function
> calc.c:1369: error: 'yylloc.first_line' may be used uninitialized in this 
> function
> calc.c:1369: error: 'yylloc.last_column' may be used uninitialized in this 
> function
> calc.c:1369: error: 'yylloc.first_column' may be used uninitialized in this 
> function

274:
> ../../../tests/regression.at:1503: $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input 
> input.c $LIBS
> stderr:
> input.c: In function 'yypush_parse':
> input.c:1718:12: error: 'yylval' may be used uninitialized in this function 
> [-Werror=uninitialized]
> cc1: all warnings being treated as errors
> stdout:
> ../../../tests/regression.at:1503: exit code was 1, expected 0


> 328. push.at:24: testing Memory Leak for Early Deletion ...
> ../../../tests/push.at:73: bison -o input.c input.y
> ../../../tests/push.at:74: $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c 
> $LIBS
> stderr:
> cc1: warnings being treated as errors
> input.c: In function 'yypush_parse':
> input.c:1172: error: 'yylval' may be used uninitialized in this function
> stdout:
> ../../../tests/push.at:74: exit code was 1, expected 0
> 328. push.at:24: 328. Memory Leak for Early Deletion (push.at:24): FAILED 
> (push.at:74)

> 335. push.at:24: testing Memory Leak for Early Deletion ...
> ../../../tests/push.at:73: bison -o input.c input.y
> ../../../tests/push.at:74: $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c 
> $LIBS
> stderr:
> cc1: warnings being treated as errors
> input.c: In function 'yypush_parse':
> input.c:1172:9: error: 'yylval' may be used uninitialized in this function
> stdout:
> ../../../tests/push.at:74: exit code was 1, expected 0
> 335. push.at:24: 335. Memory Leak for Early Deletion (push.at:24): FAILED 
> (push.at:74)

So they are all push parsers with pure interface.  In this case,
the initialization of yylval and yylloc is not ensured by the
user, and the compiler, IMHO, cannot know.  So I would move
the initializations of yylval and yylloc to their definition.



commit 97401b7f78c3d8200e0efefb5a97f4eafeff0b87
Author: Akim Demaille <address@hidden>
Date:   Thu Oct 25 14:45:36 2012 +0200

    yacc.c: don't use _Pragma GCC diagnostic with 4.6
    
    Reported by Peter Simons.
    http://lists.gnu.org/archive/html/bug-bison/2012-10/msg00033.html
    
    * data/yacc.c (b4_declare_scanner_communication_variables): 4.7
    seems fine though.

diff --git a/THANKS b/THANKS
index b6a2b2d..ee05b56 100644
--- a/THANKS
+++ b/THANKS
@@ -87,6 +87,7 @@ Paul Hilfinger            address@hidden
 Per Allansson             address@hidden
 Peter Fales               address@hidden
 Peter Hamorsky            address@hidden
+Peter Simons              address@hidden
 Piotr Gackiewicz          address@hidden
 Quoc Peyrot               address@hidden
 R Blake                   address@hidden
diff --git a/data/yacc.c b/data/yacc.c
index faf1d78..e5a1d34 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -171,7 +171,7 @@ m4_define([b4_declare_scanner_communication_variables], [[
 int yychar;
 
 ]b4_pure_if([[
-#if defined __GNUC__ && (4 < __GNUC__ + (6 <= __GNUC_MINOR__))
+#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") \




reply via email to

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