[cfe-commits] r148923 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGenCXX/conditional-gnu-ext.cpp

Eli Friedman eli.friedman at gmail.com
Tue Jan 24 21:04:17 PST 2012


Author: efriedma
Date: Tue Jan 24 23:04:17 2012
New Revision: 148923

URL: http://llvm.org/viewvc/llvm-project?rev=148923&view=rev
Log:
Fix a crash for an edge case of the GNU ?: extension.


Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/test/CodeGenCXX/conditional-gnu-ext.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=148923&r1=148922&r2=148923&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Jan 24 23:04:17 2012
@@ -1999,6 +1999,8 @@
     return EmitAggExprToLValue(expr);
   }
 
+  OpaqueValueMapping binding(*this, expr);
+
   const Expr *condExpr = expr->getCond();
   bool CondExprBool;
   if (ConstantFoldsToSimpleInteger(condExpr, CondExprBool)) {
@@ -2009,8 +2011,6 @@
       return EmitLValue(live);
   }
 
-  OpaqueValueMapping binding(*this, expr);
-
   llvm::BasicBlock *lhsBlock = createBasicBlock("cond.true");
   llvm::BasicBlock *rhsBlock = createBasicBlock("cond.false");
   llvm::BasicBlock *contBlock = createBasicBlock("cond.end");

Modified: cfe/trunk/test/CodeGenCXX/conditional-gnu-ext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/conditional-gnu-ext.cpp?rev=148923&r1=148922&r2=148923&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/conditional-gnu-ext.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/conditional-gnu-ext.cpp Tue Jan 24 23:04:17 2012
@@ -140,3 +140,11 @@
   }
 
 }
+
+namespace test4 {
+  // Make sure this doesn't crash.
+  void f() {
+    const int a = 10, b = 20;
+    const int *c = &(a ?: b);
+  }
+}





More information about the cfe-commits mailing list