]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Rewriter/rewrite-modern-synchronized.m
Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3):
[FreeBSD/FreeBSD.git] / test / Rewriter / rewrite-modern-synchronized.m
1 // RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
2 // 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
3
4 typedef struct objc_object {
5     Class isa;
6 } *id;
7
8 void *sel_registerName(const char *);
9
10 id SYNCH_EXPR();
11 void SYNCH_BODY();
12 void  SYNCH_BEFORE();
13 void  SYNC_AFTER();
14
15 void 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 }
28
29 void 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 }
35
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