modern objective-c translator. Fixes a mis-translation when

of a __block struct object. // rdar://11230308

llvm-svn: 154566
This commit is contained in:
Fariborz Jahanian 2012-04-11 23:57:12 +00:00
parent e9c64d104f
commit 5811fd6cc4
2 changed files with 22 additions and 0 deletions

View File

@ -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;

View File

@ -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);
};
}