From 1a8a1ad9a1e3179ce267baa551fb17b30624b4dd Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Wed, 1 Jan 2025 15:34:51 +0200 Subject: [PATCH] Build: Use -Wimplicit-fallthrough=5 when supported 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 | 2 ++ configure.ac | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 767cc064..f5a98fa1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/configure.ac b/configure.ac index c3447b2e..3eef0aea 100644 --- a/configure.ac +++ b/configure.ac @@ -1299,6 +1299,8 @@ AS_IF([test "$GCC" = yes], [ -Wmissing-prototypes \ -Wmissing-declarations \ -Wredundant-decls \ + -Wimplicit-fallthrough \ + -Wimplicit-fallthrough=5 \ \ -Wc99-compat \ -Wc11-extensions \