]> granicus.if.org Git - clang/commitdiff
When checking whether a return statement returns a stack-local
authorDouglas Gregor <dgregor@apple.com>
Thu, 21 Oct 2010 16:21:08 +0000 (16:21 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 21 Oct 2010 16:21:08 +0000 (16:21 +0000)
variable, handle conditional operators involving a
throw-expression. Fixes GCC DejaGNU's g++.dg/template/cond4.C.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117027 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp

index fccbe92d6f926ff1baf93a9d8e805b7ec0e161f7..4ed39e2a4b7b02eeeb23625752adaee39702b6be 100644 (file)
@@ -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