bison-patches
[Top][All Lists]
Advanced

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

[PATCH 3/5] glr2.cc: disable GCC 4.6 warning


From: Akim Demaille
Subject: [PATCH 3/5] glr2.cc: disable GCC 4.6 warning
Date: Thu, 17 Sep 2020 19:40:56 +0200

    231. conflicts.at:1096: testing Syntax error in consistent error state: 
glr2.cc ...
    tests/conflicts.at:1096: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o input 
input.cc $LIBS
    input.cc: In member function 'YYRESULTTAG 
glr_stack::yyresolveValue(glr_state*)':
    input.cc:2674:36: error: 'yysval' may be used uninitialized in this 
function [-Werror=uninitialized]

Do not initialize the variable: this way ASAN can really make sure we
do set it to a proper value.
If we initialize it, ASAN would report nothing.

* data/skeletons/c.m4 (YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN): Disable
GCC 4.6's -Wuninitialized.
* data/skeletons/glr2.cc: Disable the warning locally.
---
 README-hacking.md      | 20 ++++++++++++++++++++
 data/skeletons/c.m4    | 10 ++++++++--
 data/skeletons/glr2.cc |  2 ++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/README-hacking.md b/README-hacking.md
index b5245bb9..10fba1fd 100644
--- a/README-hacking.md
+++ b/README-hacking.md
@@ -560,6 +560,26 @@ re-run the tests, run:
     make check
 
 
+## Docker
+
+Running old compilers is not very easy.  Docker can be used for some of
+them.  Have a look at .travis.yml for setups.  Move the tarball in /tmp and
+run, for instance:
+
+```
+docker run -v /tmp:/tmp -it ubuntu:xenial
+```
+
+### GCC 4.6
+On Ubuntu Xenial.
+
+```
+apt-get update
+apt-get install software-properties-common
+apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
+apt-get update
+apt-get install -y gcc-4.6 g++-4.6 m4 make
+```
 
 Release Procedure
 =================
diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index c41db4d1..b3a63076 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -394,12 +394,18 @@ dnl use C' _Noreturn in C++, to avoid -Wc11-extensions 
warnings.
 # define YYUSE(E) /* empty */
 #endif
 
-#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + 
__GNUC_MINOR__
 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                            \
+#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + 
__GNUC_MINOR__
+# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
+#  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
+    _Pragma ("GCC diagnostic push")                                     \
+    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
+# else
+#  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
     _Pragma ("GCC diagnostic push")                                     \
     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# endif
 # define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
     _Pragma ("GCC diagnostic pop")
 #else
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 55dc3164..343489ab 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -2551,7 +2551,9 @@ public:
     if (yyflag == yyok)
       {
         yys->yyresolved = true;
+        YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
         yys->semanticVal() = yysval;
+        YY_IGNORE_MAYBE_UNINITIALIZED_END
       }
     else
       yys->setFirstVal(YY_NULLPTR);
-- 
2.28.0




reply via email to

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