diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 8ab4a44f40..dee9d4ce9b 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -158,6 +158,8 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) { BlockHasCopyDispose |= subBlockHasCopyDispose; Elts[3] = Fn; + // FIXME: Don't use BlockHasCopyDispose, it is set more often then necessary, for + // example: { ^{ __block int i; ^{ i = 1; }(); }(); } if (subBlockHasCopyDispose) flags |= BLOCK_HAS_COPY_DISPOSE; @@ -557,7 +559,6 @@ BlockModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) { subBlockHasCopyDispose); assert(subBlockSize == BlockLiteralSize && "no imports allowed for global block"); - assert(!subBlockHasCopyDispose && "no imports allowed for global block"); // isa LiteralFields[0] = getNSConcreteGlobalBlock(); diff --git a/test/CodeGen/blocks.c b/test/CodeGen/blocks.c index c7fe3a91d2..39c5b06b17 100644 --- a/test/CodeGen/blocks.c +++ b/test/CodeGen/blocks.c @@ -22,5 +22,9 @@ void *P = ^{ void *Q = __func__; }; +void (^test1)(void) = ^(void) { + __block int i; + ^ { i = 1; }(); +}; // RUN: true