help-bison
[Top][All Lists]
Advanced

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

Re: new pacification suggestion?


From: Akim Demaille
Subject: Re: new pacification suggestion?
Date: Tue, 20 Nov 2018 21:01:39 +0100

Hi Uxio,

Thanks for the report.  I’m installing this (in master).

commit 09303ceb3efad33e218acc7d0aa6f9435838192c
Author: Akim Demaille <address@hidden>
Date:   Tue Nov 20 20:54:02 2018 +0100

    warning: avoid warnings about unreachable code
    
    Reported by Uxio Prego.
    https://lists.gnu.org/archive/html/help-bison/2018-11/msg00031.html
    
    * configure.ac: Use -Wunreachable-code when supported.
    * data/c++.m4, data/lalr1.cc, data/yacc.c: Remove surprising remains
    of lint directives.
    Rather, use double-parens, which is the documented way to pacify
    clang's warnings.

diff --git a/THANKS b/THANKS
index 3d61e148..d1ad7bab 100644
--- a/THANKS
+++ b/THANKS
@@ -171,6 +171,7 @@ Tom Tromey                address@hidden
 Tommy Nordgren            address@hidden
 Troy A. Johnson           address@hidden
 Tys Lefering              address@hidden
+Uxio Prego                address@hidden
 Valentin Tolmer           address@hidden
 Victor Khomenko           address@hidden
 Vin Shelton               address@hidden
diff --git a/configure.ac b/configure.ac
index 3d55f08c..a3a595f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,7 +96,8 @@ AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test 
"$enable_gcc_warnings" = yes])
 if test "$enable_gcc_warnings" = yes; then
   warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
     -fparse-all-comments -Wdocumentation
-    -Wformat -Wnull-dereference -Wpointer-arith -Wwrite-strings'
+    -Wformat -Wnull-dereference -Wpointer-arith -Wunreachable-code
+    -Wwrite-strings'
   warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
   warn_cxx='-Wnoexcept'
   # Warnings for the test suite only.
diff --git a/data/c++.m4 b/data/c++.m4
index 07899bd8..023f3736 100644
--- a/data/c++.m4
+++ b/data/c++.m4
@@ -604,7 +604,7 @@ m4_define([b4_yylloc_default_define],
         {                                                               \
           (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end;      \
         }                                                               \
-    while (/*CONSTCOND*/ false)
+    while (false)
 # endif
 ]])
 
diff --git a/data/lalr1.cc b/data/lalr1.cc
index 8486f9e8..db35c543 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -495,7 +495,7 @@ m4_if(b4_prefix, [yy], [],
 
 #else // !]b4_api_PREFIX[DEBUG
 
-# define YYCDEBUG if (false) std::cerr
+# define YYCDEBUG if ((false)) std::cerr
 # define YY_SYMBOL_PRINT(Title, Symbol)  YYUSE (Symbol)
 # define YY_REDUCE_PRINT(Rule)           static_cast<void> (0)
 # define YY_STACK_PRINT()                static_cast<void> (0)
@@ -974,7 +974,7 @@ b4_dollar_popdef])[]dnl
     /* Pacify compilers like GCC when the user code never invokes
        YYERROR and the label yyerrorlab therefore never appears in user
        code.  */
-    if (false)
+    if ((false))
       goto yyerrorlab;
     /* Do not reclaim the symbols of the rule whose action triggered
        this YYERROR.  */
diff --git a/data/yacc.c b/data/yacc.c
index dc8d38e7..16c96b27 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -1780,7 +1780,7 @@ yyerrorlab:
   /* Pacify compilers like GCC when the user code never invokes
      YYERROR and the label yyerrorlab therefore never appears in user
      code.  */
-  if (/*CONSTCOND*/ 0)
+  if ((0))
      goto yyerrorlab;
 
   /* Do not reclaim the symbols of the rule whose action triggered




reply via email to

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