]> granicus.if.org Git - clang/commitdiff
ObjectiveC modern translator: Provide proper cast of
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 17 Sep 2013 17:51:48 +0000 (17:51 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 17 Sep 2013 17:51:48 +0000 (17:51 +0000)
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

lib/Rewrite/Frontend/RewriteModernObjC.cpp
test/Rewriter/rewrite-modern-synchronized.m

index 697d1009fa83359a53342d79b15587b48c9b3b54..ecd509610a71d60bce9444153075329b7bb35a32 100644 (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++;
index e89533930388e149ce7aae8da106d3d6dcc7773b..17c8e9a4ad4f8be0986747bee7a45c5dedee7520 100644 (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