diff options
-rw-r--r-- | lib/CodeGen/CGExprComplex.cpp | 1 | ||||
-rw-r--r-- | test/CodeGen/capture-complex-expr-in-block.c | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp index 1a27d1322b..c7b9a30716 100644 --- a/lib/CodeGen/CGExprComplex.cpp +++ b/lib/CodeGen/CGExprComplex.cpp @@ -119,6 +119,7 @@ public: // l-values. ComplexPairTy VisitDeclRefExpr(const Expr *E) { return EmitLoadOfLValue(E); } + ComplexPairTy VisitBlockDeclRefExpr(const Expr *E) { return EmitLoadOfLValue(E); } ComplexPairTy VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { return EmitLoadOfLValue(E); } diff --git a/test/CodeGen/capture-complex-expr-in-block.c b/test/CodeGen/capture-complex-expr-in-block.c new file mode 100644 index 0000000000..c38823707c --- /dev/null +++ b/test/CodeGen/capture-complex-expr-in-block.c @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 | FileCheck %s +// rdar://10033986 + +typedef void (^BLOCK)(void); +int main () +{ + _Complex double c; + BLOCK b = ^() { + _Complex double z; + z = z + c; + }; + b(); +} + +// CHECK: define internal void @__main_block_invoke_0 +// CHECK: [[C1:%.*]] = alloca { double, double }, align 8 +// CHECK: [[C1]].realp = getelementptr inbounds { double, double }* [[C1]], i32 0, i32 0 +// CHECK-NEXT: [[C1]].real = load double* [[C1]].realp +// CHECK-NEXT: [[C1]].imagp = getelementptr inbounds { double, double }* [[C1]], i32 0, i32 1 +// CHECK-NEXT: [[C1]].imag = load double* [[C1]].imagp |