Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
kbuild: Enable -Wimplicit-fallthrough for clang 14.0.0+
Clang prior to 14.0.0 warns when a fallthrough annotation is in an
unreachable spot, which can occur when IS_ENABLED(CONFIG_...) in a
conditional statement prior to the fallthrough annotation such as
if (IS_ENABLED(CONFIG_...))
break;
fallthrough;
which to clang looks like
break;
fallthrough;
if CONFIG_... is enabled due to the control flow graph. Example of the
warning in practice:
sound/core/pcm_native.c:3812:3: warning: fallthrough annotation in
unreachable code [-Wimplicit-fallthrough]
fallthrough;
^
Warning on unreachable annotations makes the warning too noisy and
pointless for the kernel due to the nature of guarding some code on
configuration options so it was disabled in commit d936eb2 ("Revert
"Makefile: Enable -Wimplicit-fallthrough for Clang"").
This has been resolved in clang 14.0.0 by moving the unreachable warning
to its own flag under -Wunreachable-code, which the kernel will most
likely never enable due to situations like this.
Enable -Wimplicit-fallthrough for clang 14+ so that issues such as the
one in commit 652b444 ("habanalabs/gaudi: fix missing code in ECC
handling") can be caught before they enter the tree.
Link: ClangBuiltLinux#236
Link: llvm/llvm-project@9ed4a94
Signed-off-by: Nathan Chancellor <nathan@kernel.org>- Loading branch information