blob: 17c8e9a4ad4f8be0986747bee7a45c5dedee7520 [file] [log] [blame]
Fariborz Jahanian542125f2012-03-16 21:33:16 +00001// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
Fariborz Jahanian786e56f2013-09-17 17:51:48 +00002// 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
Fariborz Jahanian55261af2012-03-19 18:11:32 +00003
Fariborz Jahanian55261af2012-03-19 18:11:32 +00004typedef struct objc_object {
5 Class isa;
6} *id;
Fariborz Jahanian542125f2012-03-16 21:33:16 +00007
8void *sel_registerName(const char *);
9
10id SYNCH_EXPR();
11void SYNCH_BODY();
12void SYNCH_BEFORE();
13void SYNC_AFTER();
14
15void foo(id sem)
16{
17 SYNCH_BEFORE();
18 @synchronized (SYNCH_EXPR()) {
19 SYNCH_BODY();
20 return;
21 }
22 SYNC_AFTER();
23 @synchronized ([sem self]) {
24 SYNCH_BODY();
25 return;
26 }
27}
Fariborz Jahanian22e2f852012-03-17 17:46:02 +000028
29void test_sync_with_implicit_finally() {
30 id foo;
31 @synchronized (foo) {
32 return; // The rewriter knows how to generate code for implicit finally
33 }
34}
Fariborz Jahanian786e56f2013-09-17 17:51:48 +000035
36// rdar://14993814
37@interface NSObject @end
38
39@interface I : NSObject @end
40
41@implementation I
42+ (void) Meth {
43@synchronized(self) {
44}
45}
46@end