]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Turn on -Wimplicit-fallthrough by default if available
authorFlorian Weimer <fweimer@redhat.com>
Fri, 9 Aug 2024 13:34:53 +0000 (15:34 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 9 Aug 2024 13:34:53 +0000 (15:34 +0200)
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Makeconfig
configure
configure.ac

index 2d4343b604334c791bd97b485520e724974dd724..a87ff7b1d3e62e8f9e831b7672777bbca0be66b3 100644 (file)
@@ -888,7 +888,7 @@ host-test-program-cmd = $(host-built-program-cmd)
 endif
 
 # Extra flags to pass to GCC.
-+gccwarn := -Wall -Wwrite-strings -Wundef
++gccwarn := -Wall -Wwrite-strings -Wundef $(cc-option-wimplicit-fallthrough)
 ifeq ($(enable-werror),yes)
 +gccwarn += -Werror
 endif
index 1d543548cda69060e16a75b95a687695c977379a..ec0b62db3664c9ecb69e073866b59027d9f21a09 100755 (executable)
--- a/configure
+++ b/configure
@@ -7465,6 +7465,32 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -Wimplicit-fallthrough" >&5
+printf %s "checking for -Wimplicit-fallthrough... " >&6; }
+if test ${libc_cv_cc_wimplicit_fallthrough+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) if { ac_try='${CC-cc} -Werror -Wimplicit-fallthrough -xc /dev/null -S -o /dev/null'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+then :
+  libc_cv_cc_wimplicit_fallthrough=-Wimplicit-fallthrough
+else case e in #(
+  e) libc_cv_cc_wimplicit_fallthrough= ;;
+esac
+fi
+ ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_wimplicit_fallthrough" >&5
+printf "%s\n" "$libc_cv_cc_wimplicit_fallthrough" >&6; }
+config_vars="$config_vars
+cc-option-wimplicit-fallthrough = $libc_cv_cc_wimplicit_fallthrough"
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 printf %s "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
index 9cbc0bf68f19cf9204e78e95090eb794fba8a029..7c9b57789e8f3262946f018606aa368d43ef8551 100644 (file)
@@ -1468,6 +1468,15 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK([for -Wimplicit-fallthrough],
+              libc_cv_cc_wimplicit_fallthrough, [dnl
+LIBC_TRY_CC_OPTION([-Werror -Wimplicit-fallthrough],
+                  [libc_cv_cc_wimplicit_fallthrough=-Wimplicit-fallthrough],
+                  [libc_cv_cc_wimplicit_fallthrough=])
+])
+LIBC_CONFIG_VAR([cc-option-wimplicit-fallthrough],
+               [$libc_cv_cc_wimplicit_fallthrough])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then