]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Ensure -Wimplicit-fallthrough is enabled
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 27 Mar 2018 11:22:26 +0000 (12:22 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 27 Mar 2018 11:22:39 +0000 (12:22 +0100)
configure
configure.ac
m4/ax_cc.m4

index ad231e0860ce7a7165b0105b8f9b0580c996bf65..945bc3840268fa0ac91aa640337f12bcda4a00a1 100755 (executable)
--- a/configure
+++ b/configure
@@ -2471,6 +2471,8 @@ ac_config_headers="$ac_config_headers src/include/autoconf.h"
 
 
 
+
+
 
 
 
@@ -12625,6 +12627,57 @@ $as_echo "$ax_cv_cc_weverything_flag" >&6; }
     fi
   fi
 
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the compiler flag \"-Wimplicit-fallthrough\"" >&5
+$as_echo_n "checking for the compiler flag \"-Wimplicit-fallthrough\"... " >&6; }
+if ${ax_cv_cc_wimplicit_fallthrough_flag+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+
+    CFLAGS_SAVED=$CFLAGS
+    CFLAGS="$CFLAGS -Werror -Wimplicit-fallthrough"
+
+    ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ax_cv_cc_wimplicit_fallthrough_flag="yes"
+else
+  ax_cv_cc_wimplicit_fallthrough_flag="no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+    CFLAGS="$CFLAGS_SAVED"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cc_wimplicit_fallthrough_flag" >&5
+$as_echo "$ax_cv_cc_wimplicit_fallthrough_flag" >&6; }
+
+  if test "x$ax_cv_cc_wimplicit_fallthrough_flag" = "xyes"; then
+    devcflags="$devcflags -Wimplicit-fallthrough"
+  fi
+
         if test "x$llvm_address_sanitizer" = "xyes" && test "x$ax_cv_cc_clang" = "xyes"; then
                         devcflags="$devcflags -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls"
 
index 4cf8360442c4054377fc90a1b60e45bbeb0a1228..90fdd1b9465ceb968df512081fcea29130513c08 100644 (file)
@@ -1611,6 +1611,14 @@ if test "x$developer" = "xyes"; then
     fi
   fi
 
+  dnl #
+  dnl #  Older versions of GCC don't support this, but 7 seems to
+  dnl #
+  AX_CC_IMPLICIT_FALLTHROUGH_FLAG
+  if test "x$ax_cv_cc_wimplicit_fallthrough_flag" = "xyes"; then
+    devcflags="$devcflags -Wimplicit-fallthrough"
+  fi
+
   dnl #
   dnl #  If running with clang, add in ASAN
   dnl #
index e77878f6f25f2b0376426dc66071fc7da121d9cd..816ed77c21a5d19c251524a8ebf162808bec0820 100644 (file)
@@ -106,7 +106,7 @@ AC_DEFUN([AX_CC_NO_UNKNOWN_WARNING_OPTION_FLAG],[
 
   CFLAGS_SAVED=$CFLAGS
   CFLAGS="-Werror -Wno-unknown-warning-option"
-    
+
   AC_COMPILE_IFELSE(
     [AC_LANG_PROGRAM([], [[
     /*
@@ -115,14 +115,14 @@ AC_DEFUN([AX_CC_NO_UNKNOWN_WARNING_OPTION_FLAG],[
      */
     #if defined(__GNUC__) && !defined(__clang__)
         gcc sucks
-    #endif    
-    
+    #endif
+
     return 0;
     ]])],
     [ax_cv_cc_no_unknown_warning_option_flag=yes],
     [ax_cv_cc_no_unknown_warning_option_flag=no])
 
-  CFLAGS="$CFLAGS_SAVED"    
+  CFLAGS="$CFLAGS_SAVED"
   ])
 ])
 
@@ -164,6 +164,24 @@ AC_DEFUN([AX_CC_WDOCUMENTATION_FLAG],[
   ])
 ])
 
+AC_DEFUN([AX_CC_IMPLICIT_FALLTHROUGH_FLAG],[
+  AC_CACHE_CHECK([for the compiler flag "-Wimplicit-fallthrough"], [ax_cv_cc_wimplicit_fallthrough_flag],[
+
+    CFLAGS_SAVED=$CFLAGS
+    CFLAGS="$CFLAGS -Werror -Wimplicit-fallthrough"
+
+    AC_LANG_PUSH(C)
+    AC_TRY_COMPILE(
+      [],
+      [return 0;],
+      [ax_cv_cc_wimplicit_fallthrough_flag="yes"],
+      [ax_cv_cc_wimplicit_fallthrough_flag="no"])
+    AC_LANG_POP
+
+    CFLAGS="$CFLAGS_SAVED"
+  ])
+])
+
 AC_DEFUN([AX_CC_NO_DATE_TIME_FLAG],[
   AC_CACHE_CHECK([for the compiler flag "-Wno-date-time"], [ax_cv_cc_no_date_time_flag],[