diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp index 78864ec2852e326162e88c2a77f857aa8b2866ea..1687f69f47a67f6eff4df3d1103d367e48c966a3 100644 --- a/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -722,6 +722,10 @@ namespace { if (SW && SW->getSubStmt() == B.getLabel() && P->begin() == P->end()) continue; // Previous case label has no statements, good. + const LabelStmt *L = dyn_cast_or_null(P->getLabel()); + if (L && L->getSubStmt() == B.getLabel() && P->begin() == P->end()) + continue; // Case label is preceded with a normal label, good. + if (P->pred_begin() == P->pred_end()) { // The block is unreachable. // This only catches trivially unreachable blocks. for (CFGBlock::const_iterator ElIt = P->begin(), ElEnd = P->end(); diff --git a/clang/test/SemaCXX/switch-implicit-fallthrough.cpp b/clang/test/SemaCXX/switch-implicit-fallthrough.cpp index 75dda8a9617969e5de64fc2ad86ec6c8eb4db9fe..93e724e86c6b38cdd80ddb2f8c8d1ef87574171c 100644 --- a/clang/test/SemaCXX/switch-implicit-fallthrough.cpp +++ b/clang/test/SemaCXX/switch-implicit-fallthrough.cpp @@ -38,6 +38,18 @@ int fallthrough(int n) { case 68: break; } + switch (n / 15) { +label_case_70: + case 70: + n += 333; + break; + case 71: + n += 334; + goto label_case_70; + case 72: + n += 335; + break; + } switch (n / 20) { case 7: n += 400;