]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Disable -Wimplicit-fallthrough when clang is in use
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 22 Aug 2025 22:55:24 +0000 (15:55 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 22 Aug 2025 23:32:02 +0000 (16:32 -0700)
Clang's -Wimplicit-fallthrough warning, which flags unannotated
fall-through in switch statements, does not recognize specific comments
like /* FALLTHROUGH */ for suppressing the warning, unlike GCC.  Since
fall through comments are used extensively in glibc, disable
-Wimplicit-fallthrough when clang is in use.

This fixes BZ #33312.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
configure
configure.ac

index 180e49d95bea828f41ee1b3af3d12fbdce06c0df..a2ab404d9b424f7139a2b44f5bb1f86e10c96f04 100755 (executable)
--- a/configure
+++ b/configure
@@ -8021,6 +8021,9 @@ CC="$saved_CC"
 
 fi
 
+if test $libc_cv_test_clang = yes; then
+  libc_cv_test_cc_wimplicit_fallthrough=
+fi
 config_vars="$config_vars
 cc-option-wimplicit-fallthrough = $libc_cv_cc_wimplicit_fallthrough"
 
index 4480ae83bb31a59b1d910e3ebc750512c4219b17..cababbf3f31590e0ad47bb031970f9778f1dc5b4 100644 (file)
@@ -1590,6 +1590,14 @@ LIBC_TRY_CC_AND_TEST_CC_OPTION([for -Wimplicit-fallthrough],
   libc_cv_test_cc_wimplicit_fallthrough,
   [libc_cv_test_cc_wimplicit_fallthrough=-Wimplicit-fallthrough],
   [libc_cv_test_cc_wimplicit_fallthrough=])
+dnl Clang's -Wimplicit-fallthrough warning, which flags unannotated
+dnl fall-through in switch statements, does not recognize specific
+dnl comments like /* FALLTHROUGH */ for suppressing the warning, unlike
+dnl GCC.  Since fall through comments are used extensively in glibc,
+dnl disable -Wimplicit-fallthrough when clang is in use.
+if test $libc_cv_test_clang = yes; then
+  libc_cv_test_cc_wimplicit_fallthrough=
+fi
 LIBC_CONFIG_VAR([cc-option-wimplicit-fallthrough],
                [$libc_cv_cc_wimplicit_fallthrough])
 AC_SUBST(libc_cv_test_cc_wimplicit_fallthrough)