diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-01-25 20:44:56 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-01-25 20:44:56 +0000 |
commit | 09f15f3edf1bd324d0eef465edd5d0bdedcb84b3 (patch) | |
tree | fd4c4d6fff278d3bfd6d6dfda891dcd3911f82b7 /clang/lib/Sema | |
parent | 318cbcef91a64c433424db0941bbed74b3447e31 (diff) | |
download | bcm5719-llvm-09f15f3edf1bd324d0eef465edd5d0bdedcb84b3.tar.gz bcm5719-llvm-09f15f3edf1bd324d0eef465edd5d0bdedcb84b3.zip |
Silence unintended fallthrough diagnostic on a case label preceded with a normal label.
Summary:
It's unlikely that a fallthrough is unintended in the following code:
switch (n) {
...
label:
case 1:
...
goto label;
...
}
Reviewers: rsmith, doug.gregor
Reviewed By: doug.gregor
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D329
llvm-svn: 173486
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/AnalysisBasedWarnings.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp index 78864ec2852..1687f69f47a 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<LabelStmt>(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(); |