Skip to content

Commit

Permalink
[clang] Add -Wimplicit-fallthrough to -Wextra
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vegerot committed Jul 7, 2024
1 parent f767295 commit 2ba0fe2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang/include/clang/Basic/DiagnosticGroups.td
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ def Extra : DiagGroup<"extra", [
StringConcatation,
FUseLdPath,
CastFunctionTypeMismatch,
ImplicitFallthrough,
]>;

def Most : DiagGroup<"most", [
Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/fallthrough-attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
// RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wextra %s
// RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough %s

int fallthrough_attribute_spelling(int n) {
Expand Down
1 change: 1 addition & 0 deletions clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough -DCLANG_PREFIX -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough -DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wextra -DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s

int fallthrough_compatibility_macro_from_command_line(int n) {
switch (n) {
Expand Down

0 comments on commit 2ba0fe2

Please sign in to comment.