forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang][Sema] Add -Wswitch-default warning option (llvm#73077)
Adds a warning, issued by the clang semantic analysis. The patch warns on switch which don't have the default branch. This is a counterpart of gcc's Wswitch-default.
- Loading branch information
1 parent
e1a4b00
commit c281782
Showing
5 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-default %s | ||
|
||
int f1(int a) { | ||
switch (a) { // expected-warning {{'switch' missing 'default' label}} | ||
case 1: a++; break; | ||
case 2: a += 2; break; | ||
} | ||
return a; | ||
} | ||
|
||
int f2(int a) { | ||
switch (a) { // no-warning | ||
default: | ||
; | ||
} | ||
return a; | ||
} |