Skip to content

Commit cec4051

Browse files
committed
[clang] Add -Wimplicit-fallthrough to -Wextra
This patch adds -Wimplicit-fallthrough to -Wextra. GCC already includes it in -Wextra. This patch also adds a test to check that -Wimplicit-fallthrough is included in -Wextra. Note: This patch may regress performance when building with -Wextra. This is because -Wextra requires forming a CFG for every function.
1 parent eb83d32 commit cec4051

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,7 @@ def Extra : DiagGroup<"extra", [
10671067
StringConcatation,
10681068
FUseLdPath,
10691069
CastFunctionTypeMismatch,
1070+
ImplicitFallthrough,
10701071
]>;
10711072

10721073
def Most : DiagGroup<"most", [

clang/test/Sema/fallthrough-attr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
33
// RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
44
// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
5+
// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wextra %s
56
// RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough %s
67

78
int fallthrough_attribute_spelling(int n) {

clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough -DCLANG_PREFIX -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
44
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
55
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough -DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
6+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wextra -DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
67

78
int fallthrough_compatibility_macro_from_command_line(int n) {
89
switch (n) {

0 commit comments

Comments
 (0)