summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-10-21 16:21:08 +0000
committerDouglas Gregor <dgregor@apple.com>2010-10-21 16:21:08 +0000
commit270b2ef0e7ffcb51b995348968f16ae5ffbe7663 (patch)
tree876aa878ca138187dbafbe11a1ba78e7dfcd57ab /clang/lib/Sema/SemaChecking.cpp
parentebdb43d54da36ff71a319a2a34cf891bf0bd3e82 (diff)
downloadbcm5719-llvm-270b2ef0e7ffcb51b995348968f16ae5ffbe7663.tar.gz
bcm5719-llvm-270b2ef0e7ffcb51b995348968f16ae5ffbe7663.zip
When checking whether a return statement returns a stack-local
variable, handle conditional operators involving a throw-expression. Fixes GCC DejaGNU's g++.dg/template/cond4.C. llvm-svn: 117027
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index fccbe92d6f9..4ed39e2a4b7 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1923,11 +1923,18 @@ static DeclRefExpr* EvalAddr(Expr *E) {
ConditionalOperator *C = cast<ConditionalOperator>(E);
// Handle the GNU extension for missing LHS.
- if (Expr *lhsExpr = C->getLHS())
- if (DeclRefExpr* LHS = EvalAddr(lhsExpr))
- return LHS;
+ if (Expr *lhsExpr = C->getLHS()) {
+ // In C++, we can have a throw-expression, which has 'void' type.
+ if (!lhsExpr->getType()->isVoidType())
+ if (DeclRefExpr* LHS = EvalAddr(lhsExpr))
+ return LHS;
+ }
+
+ // In C++, we can have a throw-expression, which has 'void' type.
+ if (C->getRHS()->getType()->isVoidType())
+ return NULL;
- return EvalAddr(C->getRHS());
+ return EvalAddr(C->getRHS());
}
// For casts, we need to handle conversions from arrays to
OpenPOWER on IntegriCloud