blocks: Support capturing complex variable in block.

// rdar://10033896

llvm-svn: 139041
This commit is contained in:
Fariborz Jahanian 2011-09-02 21:33:44 +00:00
parent a216debb37
commit 2bb8270e6f
2 changed files with 21 additions and 0 deletions

View File

@ -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);
}

View File

@ -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