[PATCH] Disable -Wimplicit-fallthrough when clang is in use
H.J. Lu
hjl.tools@gmail.com
Fri Aug 22 22:55:24 GMT 2025
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>
---
configure | 3 +++
configure.ac | 8 ++++++++
2 files changed, 11 insertions(+)
diff --git a/configure b/configure
index c06f68a827..1ee36947df 100755
--- a/configure
+++ b/configure
@@ -8019,6 +8019,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"
diff --git a/configure.ac b/configure.ac
index ccaaf70e1d..7eec66933e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)
--
2.50.1
More information about the Libc-alpha
mailing list