]> Savannah Git Hosting - gnulib.git/commitdiff
manywarnings: update for GCC 7
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 16 May 2017 16:23:52 +0000 (09:23 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 16 May 2017 16:32:31 +0000 (09:32 -0700)
* build-aux/gcc-warning.spec:
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC):
Add GCC 7 warnings, notably -Wimplicit-fallthrough=5, which
requires a non-comment fallthrough attribute.  This is a bit
cleaner than the comment versions.
* lib/strftime.c, lib/dfa.c, lib/fnmatch.c, lib/mbrtowc.c:
* lib/vasnprintf.c, tests/macros.h (FALLTHROUGH): New macro.
Use it whenever one switch case falls through into the next.

12 files changed:
ChangeLog
build-aux/gcc-warning.spec
lib/dfa.c
lib/fnmatch.c
lib/fnmatch_loop.c
lib/mbrtowc.c
lib/strftime.c
lib/vasnprintf.c
m4/manywarnings.m4
tests/macros.h
tests/test-mbrtowc.c
tests/test-sigpipe.c

index 2fa97a247117e30431d6499e6bb4f675cc4f26c7..ec82d0896df2382ff0d06dee02af256c86f1cf45 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2017-05-16  Paul Eggert  <eggert@cs.ucla.edu>
+
+       manywarnings: update for GCC 7
+       * build-aux/gcc-warning.spec:
+       * m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC):
+       Add GCC 7 warnings, notably -Wimplicit-fallthrough=5, which
+       requires a non-comment fallthrough attribute.  This is a bit
+       cleaner than the comment versions.
+       * lib/strftime.c, lib/dfa.c, lib/fnmatch.c, lib/mbrtowc.c:
+       * lib/vasnprintf.c, tests/macros.h (FALLTHROUGH): New macro.
+       Use it whenever one switch case falls through into the next.
+
 2017-05-15  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool: Fix generated code when libtests contains module 'alloca'.
index 8c3901770c0e7fc0a59c1e2f16e85ced83566b8e..9b9c39faf2601239f4581457dc09787a39f9c085 100644 (file)
@@ -6,7 +6,14 @@
 -Waggregate-return                     obsolescent
 -Waliasing                             fortran
 -Walign-commons                                fortran
+-Waligned-new                          c++
+-Waligned-new=[none|global|all]                c++
+-Walloca                               we like alloca in small doses
+-Walloca-larger-than=<number>          FIXME: choose something sane?
+-Walloc-size-larger-than=              handled specially by gl_MANYWARN_ALL_GCC
+-Walloc-zero                           Gnulib fixes this problem
 -Wampersand                            fortran
+-Wargument-mismatch                    fortran
 -Warray-bounds                         covered by -Warray-bounds=
 -Warray-bounds=                                handled specially by gl_MANYWARN_ALL_GCC
 -Warray-temporaries                    fortran
@@ -15,6 +22,8 @@
 -Wc++0x-compat                         c++
 -Wc++11-compat                         c++
 -Wc++14-compat                         c++
+-Wc++17-compat                         c++
+-Wc++1z-compat                         c++
 -Wc-binding-type                       fortran
 -Wc90-c99-compat                       c compatibility
 -Wc99-c11-compat                       c compatibility
 -Wfloat-equal                          FIXME maybe? borderline.  some will want this
 -Wformat                               covered by -Wformat=2
 -Wformat=                              gcc --help=warnings artifact
+-Wformat-overflow                      covered by -Wformat-overflow=2
+-Wformat-overflow=                     handled specially by gl_MANYWARN_ALL_GCC
+-Wformat-truncation                    covered by -Wformat-truncation=2
+-Wformat-truncation=                   handled specially by gl_MANYWARN_ALL_GCC
 -Wframe-larger-than=<number>           FIXME: choose something sane?
 -Wfunction-elimination                 fortran
+-Wimplicit-fallthrough                 covered by -Wimplicit-fallthrough=2
+-Wimplicit-fallthrough=                        handled specially by gl_MANYWARN_ALL_GCC
 -Wimplicit-interface                   fortran
 -Wimplicit-procedure                   fortran
 -Winherited-variadic-ctor              c++
 -Wmultiple-inheritance                 c++ and objc++
 -Wnamespaces                           c++
 -Wnoexcept                             c++
+-Wnoexcept-type                                c++
 -Wnon-template-friend                  c++
 -Wnon-virtual-dtor                     c++
 -Wnormalized                           covered by -Wnormalized=
--Wnormalized=<none|id|nfc|nfkc>                handled specially by gl_MANYWARN_ALL_GCC
+-Wnormalized=[none|id|nfc|nfkc]                handled specially by gl_MANYWARN_ALL_GCC
 -Wold-style-cast                       c++ and objc++
 -Woverloaded-virtual                   c++
 -Woverride-init-side-effects           c++ and objc++
 -Wrealloc-lhs                          fortran
 -Wrealloc-lhs-all                      fortran
 -Wredundant-decls                      FIXME maybe? many _gl_cxxalias_dummy FPs
+-Wregister                             c++ and objc++
 -Wreorder                              c++ and objc++
 -Wselector                             objc and objc++
 -Wshadow-ivar                          objc
+-Wshadow=compatible-local              covered by -Wshadow
+-Wshadow-compatible-local              covered by -Wshadow
+-Wshadow=global                                covered by -Wshadow
+-Wshadow=local                         covered by -Wshadow
+-Wshadow-local                         covered by -Wshadow
 -Wshift-overflow                       covered by -Wshift-overflow=2
 -Wshift-overflow=                      gcc --help=warnings artifact
 -Wsign-compare                         FIXME maybe? borderline.  some will want this
 -Wsign-conversion                      FIXME maybe? borderline.  some will want this
 -Wsign-promo                           c++ and objc++
 -Wsized-deallocation                   c++ and objc++
--Wstack-usage=                         FIXME: choose something sane?
+-Wstack-usage=<number>                 FIXME: choose something sane?
 -Wstrict-aliasing=                     FIXME: choose something sane?
 -Wstrict-null-sentinel                 c++ and objc++
 -Wstrict-overflow=                     FIXME: choose something sane?
 -Wstrict-selector-match                        objc and objc++
+-Wstringop-overflow                    covered by -Wstringop-overflow=
+-Wstringop-overflow=                   handled specially by gl_MANYWARN_ALL_GCC
 -Wsubobject-linkage                    c++ and objc++
 -Wsuggest-override                     c++ and objc++
 -Wsurprising                           fortran
 -Wtraditional-conversion               obsolescent
 -Wundeclared-selector                  objc and objc++
 -Wundef                                        FIXME maybe? too many false positives
+-Wundefined-do-loop                    fortran
 -Wunderflow                            fortran
 -Wunreachable-code                     obsolescent no-op
 -Wunsuffixed-float-constants           triggers warning in gnulib's timespec.h
 -Wuseless-cast                         c++ and objc++
 -Wvirtual-inheritance                  c++
 -Wvirtual-move-assign                  c++
+-Wvla-larger-than=<number>             handled specially by gl_MANYWARN_ALL_GCC
 -Wzero-as-null-pointer-constant                c++ and objc++
 -Wzerotrip                             fortran
 -frequire-return-statement             go
index e97dae1c24f8e7791f3ba330475da7edc1616963..e08e63a56e731454c6b8fd7b2b4df73fb7426b5e 100644 (file)
--- a/lib/dfa.c
+++ b/lib/dfa.c
@@ -54,6 +54,14 @@ isasciidigit (char c)
 #include "xalloc.h"
 #include "localeinfo.h"
 
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+#  define FALLTHROUGH ((void) 0)
+# else
+#  define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
 #ifndef MIN
 # define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
@@ -1614,10 +1622,10 @@ addtok_mb (struct dfa *dfa, token t, char mbprop)
 
     case BACKREF:
       dfa->fast = false;
-      /* fallthrough */
+      FALLTHROUGH;
     default:
       dfa->nleaves++;
-      /* fallthrough */
+      FALLTHROUGH;
     case EMPTY:
       dfa->parse.depth++;
       break;
@@ -2414,8 +2422,7 @@ dfaanalyze (struct dfa *d, bool searchflag)
                 copy (&merged, &d->follows[pos[j].index]);
               }
           }
-          /* fallthrough */
-
+          FALLTHROUGH;
         case QMARK:
           /* A QMARK or STAR node is automatically nullable.  */
           if (d->tokens[i] != PLUS)
@@ -3331,8 +3338,7 @@ dfa_supported (struct dfa const *d)
         case NOTLIMWORD:
           if (!d->localeinfo.multibyte)
             continue;
-          /* fallthrough */
-
+          FALLTHROUGH;
         case BACKREF:
         case MBCSET:
           return false;
@@ -3441,7 +3447,7 @@ dfassbuild (struct dfa *d)
               sup->tokens[j++] = EMPTY;
               break;
             }
-          /* fallthrough */
+          FALLTHROUGH;
         default:
           sup->tokens[j++] = d->tokens[i];
           if ((0 <= d->tokens[i] && d->tokens[i] < NOTCHAR)
index 90134bd113a59c9c5ab2dc8dfd209fe83cf7b0a2..3a63f355ccd91bfbf3d4de442de572f8dfcf4bb1 100644 (file)
@@ -65,6 +65,14 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
 
 #include "flexmember.h"
 
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+#  define FALLTHROUGH ((void) 0)
+# else
+#  define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
 /* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set.  */
 #define NO_LEADING_PERIOD(flags) \
   ((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD))
index 9f3c2e847555c5f859a17db6662253411639ed38..aed847d797e31fd856e3e0816b4e0f6f40b7361f 100644 (file)
@@ -960,7 +960,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
               new_no_leading_period = true;
               break;
             }
-          /* FALLTHROUGH */
+          FALLTHROUGH;
         default:
         normal_match:
           if (n == string_end || c != FOLD ((UCHAR) *n))
@@ -1114,8 +1114,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
     case L_('*'):
       if (FCT (p, string, string_end, no_leading_period, flags) == 0)
         return 0;
-      /* FALLTHROUGH */
-
+      FALLTHROUGH;
     case L_('+'):
       do
         {
@@ -1151,8 +1150,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
     case L_('?'):
       if (FCT (p, string, string_end, no_leading_period, flags) == 0)
         return 0;
-      /* FALLTHROUGH */
-
+      FALLTHROUGH;
     case L_('@'):
       do
         /* I cannot believe it but 'strcat' is actually acceptable
index d4809f6b0ef682c1885598302e7765a67803a975..7415ffffd528fc545282e3ec09a07aee25707e01 100644 (file)
 # include "streq.h"
 # include "verify.h"
 
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+#  define FALLTHROUGH ((void) 0)
+# else
+#  define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
 
 verify (sizeof (mbstate_t) >= 4);
 
@@ -74,10 +81,10 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
         break;
       case 3:
         buf[2] = pstate[3];
-        /*FALLTHROUGH*/
+        FALLTHROUGH;
       case 2:
         buf[1] = pstate[2];
-        /*FALLTHROUGH*/
+        FALLTHROUGH;
       case 1:
         buf[0] = pstate[1];
         p = buf;
index 8091f3d08ed45aa7813a8a20ad8296a62d4ebd71..e05c872167f14a9b1ea1f98168862b0aa094495b 100644 (file)
@@ -68,6 +68,14 @@ extern char *tzname[];
 #include <string.h>
 #include <stdbool.h>
 
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+#  define FALLTHROUGH ((void) 0)
+# else
+#  define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
 #ifdef COMPILE_WIDE
 # include <endian.h>
 # define CHAR_T wchar_t
@@ -1138,8 +1146,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
 #ifndef _NL_CURRENT
           format_char = L_('p');
 #endif
-          /* FALLTHROUGH */
-
+          FALLTHROUGH;
         case L_('p'):
           if (change_case)
             {
@@ -1474,7 +1481,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
 
         case L_('\0'):          /* GNU extension: % at end of format.  */
             --f;
-            /* Fall through.  */
+            FALLTHROUGH;
         default:
           /* Unknown format; output the format, including the '%',
              since this is most likely the right thing to do if a
index 839f79060b53e420fae02d92bbf13e78c4362ee6..9c2af0e45e00d437b1d1ccb8f6d8952353d06fbc 100644 (file)
 # include "fpucw.h"
 #endif
 
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+#  define FALLTHROUGH ((void) 0)
+# else
+#  define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
 /* Default parameters.  */
 #ifndef VASNPRINTF
 # if WIDE_CHAR_VERSION
@@ -4837,7 +4845,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                     *fbp++ = 'l';
 # endif
 #endif
-                    /*FALLTHROUGH*/
+                    FALLTHROUGH;
                   case TYPE_LONGINT:
                   case TYPE_ULONGINT:
 #if HAVE_WINT_T
index 0f06adecfbb511b049d70c3097e0c8e07839d952..2d35eff6a2cf2981469f14212b11d70fec251561 100644 (file)
@@ -99,12 +99,11 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
   # comm -3 \
   #  <(sed -n 's/^  *\(-[^ ]*\) .*/\1/p' manywarnings.m4 | sort) \
   #  <(gcc --help=warnings | sed -n 's/^  \(-[^ ]*\) .*/\1/p' | sort |
-  #      grep -v -x -f <(
+  #      grep -v -x -F -f <(
   #         awk '/^[^#]/ {print $1}' ../build-aux/gcc-warning.spec))
 
   gl_manywarn_set=
-  for gl_manywarn_item in \
-    -fno-common \
+  for gl_manywarn_item in -fno-common \
     -W \
     -Wabi \
     -Waddress \
@@ -113,6 +112,8 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wattributes \
     -Wbad-function-cast \
     -Wbool-compare \
+    -Wbool-operation \
+    -Wbuiltin-declaration-mismatch \
     -Wbuiltin-macro-redefined \
     -Wcast-align \
     -Wchar-subscripts \
@@ -122,6 +123,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wcomments \
     -Wcoverage-mismatch \
     -Wcpp \
+    -Wdangling-else \
     -Wdate-time \
     -Wdeprecated \
     -Wdeprecated-declarations \
@@ -131,10 +133,13 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wdiscarded-qualifiers \
     -Wdiv-by-zero \
     -Wdouble-promotion \
+    -Wduplicated-branches \
     -Wduplicated-cond \
+    -Wduplicate-decl-specifier \
     -Wempty-body \
     -Wendif-labels \
     -Wenum-compare \
+    -Wexpansion-to-defined \
     -Wextra \
     -Wformat-contains-nul \
     -Wformat-extra-args \
@@ -155,6 +160,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Winit-self \
     -Winline \
     -Wint-conversion \
+    -Wint-in-bool-context \
     -Wint-to-pointer-cast \
     -Winvalid-memory-model \
     -Winvalid-pch \
@@ -163,6 +169,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wlogical-op \
     -Wmain \
     -Wmaybe-uninitialized \
+    -Wmemset-elt-size \
     -Wmemset-transposed-args \
     -Wmisleading-indentation \
     -Wmissing-braces \
@@ -188,9 +195,12 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wpacked-bitfield-compat \
     -Wparentheses \
     -Wpointer-arith \
+    -Wpointer-compare \
     -Wpointer-sign \
     -Wpointer-to-int-cast \
     -Wpragmas \
+    -Wpsabi \
+    -Wrestrict \
     -Wreturn-local-addr \
     -Wreturn-type \
     -Wscalar-storage-order \
@@ -214,6 +224,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wswitch \
     -Wswitch-bool \
     -Wswitch-default \
+    -Wswitch-unreachable \
     -Wsync-nand \
     -Wsystem-headers \
     -Wtautological-compare \
@@ -247,10 +258,18 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
 
   # gcc --help=warnings outputs an unusual form for these options; list
   # them here so that the above 'comm' command doesn't report a false match.
+  # Would prefer "min (PTRDIFF_MAX, SIZE_MAX)", but it must be a literal:
+  ptrdiff_max_max=9223372036854775807
+  gl_manywarn_set="$gl_manywarn_set -Walloc-size-larger-than=$ptrdiff_max_max"
   gl_manywarn_set="$gl_manywarn_set -Warray-bounds=2"
+  gl_manywarn_set="$gl_manywarn_set -Wformat-overflow=2"
+  gl_manywarn_set="$gl_manywarn_set -Wformat-truncation=2"
+  gl_manywarn_set="$gl_manywarn_set -Wimplicit-fallthrough=5"
   gl_manywarn_set="$gl_manywarn_set -Wnormalized=nfc"
   gl_manywarn_set="$gl_manywarn_set -Wshift-overflow=2"
+  gl_manywarn_set="$gl_manywarn_set -Wstringop-overflow=2"
   gl_manywarn_set="$gl_manywarn_set -Wunused-const-variable=2"
+  gl_manywarn_set="$gl_manywarn_set -Wvla-larger-than=4031"
 
   # These are needed for older GCC versions.
   if test -n "$GCC"; then
index 53b270c7d98ac6f821f90b3dda7fff8b5c18e3d1..0423d061045d0e0e6eb92dae73e7f6b70165c0d3 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+#  define FALLTHROUGH ((void) 0)
+# else
+#  define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
 /* Define ASSERT_STREAM before including this file if ASSERT must
    target a stream other than stderr.  */
 #ifndef ASSERT_STREAM
index ddbe2431dc9ad00bf309a07ac660829e3113f00e..70c8a2a6bf79c73267d5d6fee5389cfc65ce3324 100644 (file)
@@ -75,7 +75,7 @@ main (int argc, char *argv[])
         default:
           if (! (c && 1 < argc && argv[1][0] == '5'))
             break;
-          /* Fall through.  */
+          FALLTHROUGH;
         case '\t': case '\v': case '\f':
         case ' ': case '!': case '"': case '#': case '%':
         case '&': case '\'': case '(': case ')': case '*':
index 48b22f104491e58495d488451e59c23bf6288f23..e75372d1d73c808acc136d400f2cf5f6b29a296d 100644 (file)
@@ -26,6 +26,8 @@ int s = SIGPIPE;
 #include <stdlib.h>
 #include <unistd.h>
 
+#include "macros.h"
+
 static void
 handler (int sig)
 {
@@ -57,7 +59,7 @@ main (int argc, char **argv)
             case 'B': /* The write() call should have failed with EPIPE.  */
               if (ret < 0 && errno == EPIPE)
                 exit (0);
-              /*FALLTHROUGH*/
+              FALLTHROUGH;
             case 'A': /* The process should silently die.  */
             case 'C': /* The handler should have been called.  */
               fprintf (stderr, "write() returned %d with error %d.\n", ret, errno);