]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
Build: Use -Wimplicit-fallthrough=5 when supported
authorLasse Collin <lasse.collin@tukaani.org>
Wed, 1 Jan 2025 13:34:51 +0000 (15:34 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Thu, 2 Jan 2025 13:43:37 +0000 (15:43 +0200)
Now that we have the FALLTHROUGH macro, use the strictest mode with
GCC so that comment-based fallthrough markings are no longer accepted.

In GCC, -Wextra includes -Wimplicit-fallthrough=3 and
-Wimplicit-fallthrough is the same as -Wimplicit-fallthrough=3.
Thus, the strict mode requires specifying -Wimplicit-fallthrough=5.

Clang has -Wimplicit-fallthrough which is *not* enabled by -Wextra.
Clang doesn't have a variant that takes an argument. Thus we need
to check for -Wimplicit-fallthrough. Do it before checking for
-Wimplicit-fallthrough=5 so that the latter overrides the former
when using GCC.

CMakeLists.txt
configure.ac

index 767cc064d17859897c76171f24a2eae37032560d..f5a98fa1b0772dbf4940e547bbbe430ec6a21bd5 100644 (file)
@@ -434,6 +434,8 @@ if(CMAKE_C_COMPILER_ID MATCHES GNU|Clang)
                 -Wmissing-prototypes
                 -Wmissing-declarations
                 -Wredundant-decls
+                -Wimplicit-fallthrough
+                -Wimplicit-fallthrough=5
 
                 -Wc99-compat
                 -Wc11-extensions
index c3447b2e9710d5c3327a5c9afb17b45f004de06b..3eef0aea9652584835a1d62bda63a9fe79426e91 100644 (file)
@@ -1299,6 +1299,8 @@ AS_IF([test "$GCC" = yes], [
                        -Wmissing-prototypes \
                        -Wmissing-declarations \
                        -Wredundant-decls \
+                       -Wimplicit-fallthrough \
+                       -Wimplicit-fallthrough=5 \
                        \
                        -Wc99-compat \
                        -Wc11-extensions \