Skip to content

Commit c9891ac

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 2e2a792 commit c9891ac

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
@@ -1212,6 +1212,7 @@ def Extra : DiagGroup<"extra", [
12121212
CastFunctionTypeMismatch,
12131213
InitStringTooLongMissingNonString,
12141214
WarnUnnecessaryVirtualSpecifier,
1215+
ImplicitFallthrough,
12151216
]>;
12161217

12171218
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)