aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-08-28 00:19:02 +0000
committerTed Kremenek <kremenek@apple.com>2010-08-28 00:19:02 +0000
commit47e331ed28c2536bec227c5e2fa094ab3d46eed1 (patch)
tree1021b3d3158ee35e8f7633c36ba4bcc0867c34ea
parent40181c4e587b8a988e691d7b46580b1a1212c535 (diff)
Explicitly handle CXXExprWithTemporaries during CFG construction by just visiting the subexpression. While we don't do anything intelligent right now, this obviates a bogus -Wunreahable-code warning reported in PR 6130.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112334 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/CFG.cpp6
-rw-r--r--test/SemaCXX/unreachable-code.cpp17
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index 3720d20c28..78979a4fee 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -390,6 +390,12 @@ tryAgain:
case Stmt::CXXCatchStmtClass:
return VisitCXXCatchStmt(cast<CXXCatchStmt>(S));
+ case Stmt::CXXExprWithTemporariesClass: {
+ // FIXME: Handle temporaries. For now, just visit the subexpression
+ // so we don't artificially create extra blocks.
+ return Visit(cast<CXXExprWithTemporaries>(S)->getSubExpr());
+ }
+
case Stmt::CXXMemberCallExprClass:
return VisitCXXMemberCallExpr(cast<CXXMemberCallExpr>(S), asc);
diff --git a/test/SemaCXX/unreachable-code.cpp b/test/SemaCXX/unreachable-code.cpp
index 528bba7d5e..40d0c00b93 100644
--- a/test/SemaCXX/unreachable-code.cpp
+++ b/test/SemaCXX/unreachable-code.cpp
@@ -39,3 +39,20 @@ void test3() {
bar(); // expected-warning {{will never be executed}}
}
}
+
+// PR 6130 - Don't warn about bogus unreachable code with throw's and
+// temporary objects.
+class PR6130 {
+public:
+ PR6130();
+ ~PR6130();
+};
+
+int pr6130(unsigned i) {
+ switch(i) {
+ case 0: return 1;
+ case 1: return 2;
+ default:
+ throw PR6130(); // no-warning
+ }
+}