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.
This commit is contained in:
Lasse Collin 2025-01-01 15:34:51 +02:00
parent 94adc996e4
commit 1a8a1ad9a1
No known key found for this signature in database
GPG Key ID: 38EE757D69184620
2 changed files with 4 additions and 0 deletions

View File

@ -434,6 +434,8 @@ if(CMAKE_C_COMPILER_ID MATCHES GNU|Clang)
-Wmissing-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wmissing-declarations
-Wredundant-decls -Wredundant-decls
-Wimplicit-fallthrough
-Wimplicit-fallthrough=5
-Wc99-compat -Wc99-compat
-Wc11-extensions -Wc11-extensions

View File

@ -1299,6 +1299,8 @@ AS_IF([test "$GCC" = yes], [
-Wmissing-prototypes \ -Wmissing-prototypes \
-Wmissing-declarations \ -Wmissing-declarations \
-Wredundant-decls \ -Wredundant-decls \
-Wimplicit-fallthrough \
-Wimplicit-fallthrough=5 \
\ \
-Wc99-compat \ -Wc99-compat \
-Wc11-extensions \ -Wc11-extensions \