[cfe-commits] r117027 - /cfe/trunk/lib/Sema/SemaChecking.cpp

Douglas Gregor dgregor at apple.com
Thu Oct 21 09:21:08 PDT 2010


Author: dgregor
Date: Thu Oct 21 11:21:08 2010
New Revision: 117027

URL: http://llvm.org/viewvc/llvm-project?rev=117027&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=117027&r1=117026&r2=117027&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Oct 21 11:21:08 2010
@@ -1923,11 +1923,18 @@
     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





More information about the cfe-commits mailing list