diff options
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 4 | ||||
-rw-r--r-- | test/CodeGenObjC/blocks-2.m | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 0b7ad05b30..2fe6754293 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -723,7 +723,9 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { } LValue CodeGenFunction::EmitBlockDeclRefLValue(const BlockDeclRefExpr *E) { - return LValue::MakeAddr(GetAddrOfBlockDecl(E), 0); + return LValue::MakeAddr(GetAddrOfBlockDecl(E), + E->getType().getCVRQualifiers(), + getContext().getObjCGCAttrKind(E->getType())); } LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) { diff --git a/test/CodeGenObjC/blocks-2.m b/test/CodeGenObjC/blocks-2.m new file mode 100644 index 0000000000..a4d8bfa6b7 --- /dev/null +++ b/test/CodeGenObjC/blocks-2.m @@ -0,0 +1,11 @@ +// RUN: clang-cc %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 && +// RUN: grep "objc_assign_strongCast" %t | count 2 && +// RUN: true + +// This should generate a strong cast. + +id test3(id x) { + __block id result; + ^{ result = x; }(); + return result; +} |