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 | c6dcea93b499b504da22f9921fc198423ad0b13b (patch) | |
tree | 2e3752a78786fdd85d901a848ef34634cd8278d9 /lib/Sema/AnalysisBasedWarnings.cpp | |
parent | f282e72d4d55680dd82f3874b739fe0e02851435 (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173486 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r-- | lib/Sema/AnalysisBasedWarnings.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index 78864ec285..1687f69f47 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/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(); |