Skip to content
Snippets Groups Projects
Commit a189d897 authored by Alexander Kornienko's avatar Alexander Kornienko
Browse files

Don't offer '[[clang::fallthrough]];' fix-it when a fall-through occurs to a

switch label immediately followed by a 'break;'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157508 91177308-0d34-0410-b5e6-96231b3b80d8
parent 976f266b
No related branches found
No related tags found
No related merge requests found
...@@ -777,8 +777,11 @@ static void DiagnoseSwitchLabelsFallthrough(Sema &S, AnalysisDeclContext &AC) { ...@@ -777,8 +777,11 @@ static void DiagnoseSwitchLabelsFallthrough(Sema &S, AnalysisDeclContext &AC) {
if (L.isMacroID()) if (L.isMacroID())
continue; continue;
if (S.getLangOpts().CPlusPlus0x) { if (S.getLangOpts().CPlusPlus0x) {
S.Diag(L, diag::note_insert_fallthrough_fixit) << const Stmt *Term = B.getTerminator();
FixItHint::CreateInsertion(L, "[[clang::fallthrough]]; "); if (!(B.empty() && Term && isa<BreakStmt>(Term))) {
S.Diag(L, diag::note_insert_fallthrough_fixit) <<
FixItHint::CreateInsertion(L, "[[clang::fallthrough]]; ");
}
} }
S.Diag(L, diag::note_insert_break_fixit) << S.Diag(L, diag::note_insert_break_fixit) <<
FixItHint::CreateInsertion(L, "break; "); FixItHint::CreateInsertion(L, "break; ");
......
...@@ -33,6 +33,8 @@ int fallthrough(int n) { ...@@ -33,6 +33,8 @@ int fallthrough(int n) {
} }
case 6: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} case 6: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}}
n += 300; n += 300;
case 66: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'break;' to avoid fall-through}}
break;
} }
switch (n / 20) { switch (n / 20) {
case 7: case 7:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment