]> granicus.if.org Git - clang/commitdiff
Ensure an insertion point at the end of a statement-expression.
authorJohn McCall <rjmccall@apple.com>
Thu, 13 Jan 2011 02:03:06 +0000 (02:03 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 13 Jan 2011 02:03:06 +0000 (02:03 +0000)
Fixes PR8967.

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

lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGExprComplex.cpp
lib/CodeGen/CGExprScalar.cpp
test/CodeGen/exprs.c

index f02145ee29864340e706f2cc775b317a98ded277..0369077797612950e9445fa91bc78eaf524523cc 100644 (file)
@@ -368,6 +368,7 @@ void AggExprEmitter::VisitBinComma(const BinaryOperator *E) {
 
 void AggExprEmitter::VisitStmtExpr(const StmtExpr *E) {
   CGF.EmitCompoundStmt(*E->getSubStmt(), true, Dest);
+  CGF.EnsureInsertPoint();
 }
 
 void AggExprEmitter::VisitBinaryOperator(const BinaryOperator *E) {
index cf1e3f11c4276f400ce0bba4870d91effd6c5702..5c4d0a560887c9d50fd9967ef9508e0a5a06c2cb 100644 (file)
@@ -313,8 +313,7 @@ ComplexPairTy ComplexExprEmitter::VisitExpr(Expr *E) {
 ComplexPairTy ComplexExprEmitter::
 VisitImaginaryLiteral(const ImaginaryLiteral *IL) {
   llvm::Value *Imag = CGF.EmitScalarExpr(IL->getSubExpr());
-  return
-        ComplexPairTy(llvm::Constant::getNullValue(Imag->getType()), Imag);
+  return ComplexPairTy(llvm::Constant::getNullValue(Imag->getType()), Imag);
 }
 
 
@@ -326,7 +325,9 @@ ComplexPairTy ComplexExprEmitter::VisitCallExpr(const CallExpr *E) {
 }
 
 ComplexPairTy ComplexExprEmitter::VisitStmtExpr(const StmtExpr *E) {
-  return CGF.EmitCompoundStmt(*E->getSubStmt(), true).getComplexVal();
+  RValue result = CGF.EmitCompoundStmt(*E->getSubStmt(), true);
+  CGF.EnsureInsertPoint();
+  return result.getComplexVal();
 }
 
 /// EmitComplexToComplexCast - Emit a cast from complex value Val to DestType.
@@ -635,7 +636,6 @@ ComplexPairTy ComplexExprEmitter::VisitBinAssign(const BinaryOperator *E) {
 
 ComplexPairTy ComplexExprEmitter::VisitBinComma(const BinaryOperator *E) {
   CGF.EmitIgnoredExpr(E->getLHS());
-  CGF.EnsureInsertPoint();
   return Visit(E->getRHS());
 }
 
index f80304d6de6b1fe64e6ed8e5ebb2655d792c6ffe..fde9f03ba7f31dd5f9df88322f3d391cee4f1098 100644 (file)
@@ -1204,8 +1204,10 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) {
 }
 
 Value *ScalarExprEmitter::VisitStmtExpr(const StmtExpr *E) {
-  return CGF.EmitCompoundStmt(*E->getSubStmt(),
-                              !E->getType()->isVoidType()).getScalarVal();
+  RValue value = CGF.EmitCompoundStmt(*E->getSubStmt(),
+                                      !E->getType()->isVoidType());
+  CGF.EnsureInsertPoint();
+  return value.getScalarVal();
 }
 
 Value *ScalarExprEmitter::VisitBlockDeclRefExpr(const BlockDeclRefExpr *E) {
index b03539333cd78781ae27212c7794a8c97fe38955..cc03be6a922a4c6bc59526876ffb5c3632e038f4 100644 (file)
@@ -166,3 +166,11 @@ void f15() {
   // CHECK-NOT: load
   // CHECK: ret void
 }
+
+// PR8967: this was crashing
+// CHECK: define void @f16()
+void f16() {
+  __extension__({ goto lbl; });
+ lbl:
+  ;
+}