diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-04-11 23:57:12 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-04-11 23:57:12 +0000 |
commit | 104dbf982582f16888fb15f9342fce9748af48c5 (patch) | |
tree | 30ea9fb55508d8d5ea19f9d5362a89e46c88b931 | |
parent | 16aac6f6eb31eb5118424773411867fc3cd5fbc6 (diff) |
modern objective-c translator. Fixes a mis-translation when
of a __block struct object. // rdar://11230308
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154566 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Rewrite/RewriteModernObjC.cpp | 4 | ||||
-rw-r--r-- | test/Rewriter/rewrite-modern-block.mm | 18 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/Rewrite/RewriteModernObjC.cpp b/lib/Rewrite/RewriteModernObjC.cpp index fd433f88c2..fd621a2a5c 100644 --- a/lib/Rewrite/RewriteModernObjC.cpp +++ b/lib/Rewrite/RewriteModernObjC.cpp @@ -4812,6 +4812,10 @@ void RewriteModernObjC::RewriteByRefVar(VarDecl *ND) { // {0, &ND, some_flag, __size=sizeof(struct __Block_byref_ND), // initializer-if-any}; bool hasInit = (ND->getInit() != 0); + // FIXME. rewriter does not support __block c++ objects which + // require construction. + if (hasInit && dyn_cast<CXXConstructExpr>(ND->getInit())) + hasInit = false; unsigned flags = 0; if (HasCopyAndDispose) flags |= BLOCK_HAS_COPY_DISPOSE; diff --git a/test/Rewriter/rewrite-modern-block.mm b/test/Rewriter/rewrite-modern-block.mm new file mode 100644 index 0000000000..c5231bfceb --- /dev/null +++ b/test/Rewriter/rewrite-modern-block.mm @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// rdar://11230308 + +typedef struct { + char byte0; + char byte1; +} CFUUIDBytes; + +void x(void *); + +void y() { + __block CFUUIDBytes bytes; + + void (^bar)() = ^{ + x(&bytes); + }; +} |