зеркало из https://github.com/microsoft/clang-1.git
modern objective-c transltion: Fixes a translation bug
of writing a __block variable being initialized with a constructed object. // rdar://11326988 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155673 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
9b94cd1b25
Коммит
65a7c685b7
|
@ -4814,8 +4814,13 @@ void RewriteModernObjC::RewriteByRefVar(VarDecl *ND, bool firstDecl,
|
|||
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;
|
||||
if (hasInit)
|
||||
if (CXXConstructExpr *CExp = dyn_cast<CXXConstructExpr>(ND->getInit())) {
|
||||
CXXConstructorDecl *CXXDecl = CExp->getConstructor();
|
||||
if (CXXDecl && CXXDecl->isDefaultConstructor())
|
||||
hasInit = false;
|
||||
}
|
||||
|
||||
unsigned flags = 0;
|
||||
if (HasCopyAndDispose)
|
||||
flags |= BLOCK_HAS_COPY_DISPOSE;
|
||||
|
|
|
@ -46,3 +46,19 @@ int rdar7547630(const char *keybuf, const char *valuebuf) {
|
|||
return BI2;
|
||||
}
|
||||
|
||||
// rdar://11326988
|
||||
typedef struct _z {
|
||||
int location;
|
||||
int length;
|
||||
} z;
|
||||
|
||||
z w(int loc, int len);
|
||||
|
||||
@interface rdar11326988
|
||||
@end
|
||||
@implementation rdar11326988
|
||||
- (void)y:(int)options {
|
||||
__attribute__((__blocks__(byref))) z firstRange = w(1, 0);
|
||||
options &= ~(1 | 2);
|
||||
}
|
||||
@end
|
||||
|
|
Загрузка…
Ссылка в новой задаче