Skip to content

Commit b7eb335

Browse files
Makefile: Enable -Wimplicit-fallthrough for Clang
With the recent fixes for fallthrough warnings, it is now possible to enable -Wimplicit-fallthrough for Clang. It's important to mention that since we have adopted the use of the pseudo-keyword macro fallthrough; we also want to avoid having more /* fall through */ comments being introduced. Notice that contrary to GCC, Clang doesn't recognize any comments as implicit fall-through markings when the -Wimplicit-fallthrough option is enabled. So, in order to avoid having more comments being introduced, we have to use the option -Wimplicit-fallthrough=5 for GCC, which similar to Clang, will cause a warning in case a code comment is intended to be used as a fall-through marking. Co-developed-by: Kees Cook <[email protected]> Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]>
1 parent 104aba8 commit b7eb335

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -797,12 +797,6 @@ KBUILD_CFLAGS += -Wno-gnu
797797
# source of a reference will be _MergedGlobals and not on of the whitelisted names.
798798
# See modpost pattern 2
799799
KBUILD_CFLAGS += -mno-global-merge
800-
else
801-
802-
# Warn about unmarked fall-throughs in switch statement.
803-
# Disabled for clang while comment to attribute conversion happens and
804-
# https://github.com/ClangBuiltLinux/linux/issues/636 is discussed.
805-
KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
806800
endif
807801

808802
# These warnings generated too much noise in a regular build.
@@ -983,6 +977,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
983977
# warn about C99 declaration after statement
984978
KBUILD_CFLAGS += -Wdeclaration-after-statement
985979

980+
# Warn about unmarked fall-throughs in switch statement.
981+
KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=5,$(call cc-option,-Wimplicit-fallthrough,))
982+
986983
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
987984
KBUILD_CFLAGS += -Wvla
988985

0 commit comments

Comments
 (0)