diff options
-rw-r--r-- | lib/CodeGen/CGBlocks.cpp | 3 | ||||
-rw-r--r-- | test/CodeGenCXX/block.cpp | 19 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 9fe31cb958..09d3125ce8 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -1850,7 +1850,8 @@ llvm::Type *CodeGenFunction::BuildByRefType(const VarDecl *D) { // int32_t __size; types.push_back(Int32Ty); - bool HasCopyAndDispose = getContext().BlockRequiresCopying(Ty); + bool HasCopyAndDispose = + (Ty->isObjCRetainableType()) || getContext().getBlockVarCopyInits(D); if (HasCopyAndDispose) { /// void *__copy_helper; types.push_back(Int8PtrTy); diff --git a/test/CodeGenCXX/block.cpp b/test/CodeGenCXX/block.cpp new file mode 100644 index 0000000000..619d8b0c7b --- /dev/null +++ b/test/CodeGenCXX/block.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks +// Just test that this doesn't crash the compiler... + +void func(void*); + +struct Test +{ + virtual void use() { func((void*)this); } + Test(Test&c) { func((void*)this); } + Test() { func((void*)this); } +}; + +void useBlock(void (^)(void)); + +int main (void) { + __block Test t; + useBlock(^(void) { t.use(); }); +} + |