ObjectiveC modern translator: Provide proper cast of

the ObjectiveC object of an @synchronized statement.
// rdar://14993814


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190874 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Fariborz Jahanian 2013-09-17 17:51:48 +00:00
parent ebaa1719fd
commit 786e56f5b4
2 changed files with 14 additions and 3 deletions

View File

@ -1904,7 +1904,7 @@ Stmt *RewriteModernObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S)
std::string buf;
SourceLocation SynchLoc = S->getAtSynchronizedLoc();
ConvertSourceLocationToLineDirective(SynchLoc, buf);
buf += "{ id _rethrow = 0; id _sync_obj = ";
buf += "{ id _rethrow = 0; id _sync_obj = (id)";
const char *lparenBuf = startBuf;
while (*lparenBuf != '(') lparenBuf++;

View File

@ -1,7 +1,6 @@
// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"Class=struct objc_class *" -D"__declspec(X)=" %t-rw.cpp
typedef struct objc_class *Class;
typedef struct objc_object {
Class isa;
} *id;
@ -33,3 +32,15 @@ void test_sync_with_implicit_finally() {
return; // The rewriter knows how to generate code for implicit finally
}
}
// rdar://14993814
@interface NSObject @end
@interface I : NSObject @end
@implementation I
+ (void) Meth {
@synchronized(self) {
}
}
@end