From: Mike Stump Date: Fri, 1 May 2009 01:31:57 +0000 (+0000) Subject: Don't assert when we think we need copy/dispose, but don't need them. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dd2fb9c5ebc02f48a5b91a9c2a5f1e4562d02a0b;p=clang Don't assert when we think we need copy/dispose, but don't need them. Radar 6838889 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70525 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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