summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2016-11-02 13:29:26 +0100
committerMark Wielaard <mjw@redhat.com>2016-11-10 11:59:00 +0100
commita3cc8182b2ae05290b0eafa74b70746d7befc0e4 (patch)
tree7d1f74f9f464b810a95dc7cd78c73930a938924a /configure.ac
parent33ca0e1b9dfb47c6f9836c7fc19d04bd34337767 (diff)
Add GCC7 -Wimplicit-fallthrough support/fixes.
GCC7 will have a new -Wimplicit-fallthrough warning. It did catch one small buglet in elflint option procession. So it seems useful to enable to make sure all swatch case fallthroughs are deliberate. Add configure check to detect whether gcc support -Wimplicit-fallthrough and enable it. Add fixes and explicit fallthrough comments where necessary. Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac10
1 files changed, 10 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index c02d4c2a..c55fb9b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -311,6 +311,16 @@ CFLAGS="$old_CFLAGS"])
AM_CONDITIONAL(HAVE_NULL_DEREFERENCE_WARNING,
[test "x$ac_cv_null_dereference" != "xno"])
+# -Wimplicit-fallthrough was added by GCC7
+AC_CACHE_CHECK([whether gcc accepts -Wimplicit-fallthrough], ac_cv_implicit_fallthrough, [dnl
+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wimplicit-fallthrough -Werror"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
+ ac_cv_implicit_fallthrough=yes, ac_cv_implicit_fallthrough=no)
+CFLAGS="$old_CFLAGS"])
+AM_CONDITIONAL(HAVE_IMPLICIT_FALLTHROUGH_WARNING,
+ [test "x$ac_cv_implicit_fallthrough" != "xno"])
+
dnl Check if we have argp available from our libc
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(