xref: /minix3/external/bsd/llvm/dist/clang/test/Rewriter/rewrite-modern-synchronized.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
2*f4a2713aSLionel Sambuc// 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*f4a2713aSLionel Sambuc
4*f4a2713aSLionel Sambuctypedef struct objc_object {
5*f4a2713aSLionel Sambuc    Class isa;
6*f4a2713aSLionel Sambuc} *id;
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambucvoid *sel_registerName(const char *);
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambucid SYNCH_EXPR();
11*f4a2713aSLionel Sambucvoid SYNCH_BODY();
12*f4a2713aSLionel Sambucvoid  SYNCH_BEFORE();
13*f4a2713aSLionel Sambucvoid  SYNC_AFTER();
14*f4a2713aSLionel Sambuc
15*f4a2713aSLionel Sambucvoid foo(id sem)
16*f4a2713aSLionel Sambuc{
17*f4a2713aSLionel Sambuc  SYNCH_BEFORE();
18*f4a2713aSLionel Sambuc  @synchronized (SYNCH_EXPR()) {
19*f4a2713aSLionel Sambuc    SYNCH_BODY();
20*f4a2713aSLionel Sambuc    return;
21*f4a2713aSLionel Sambuc  }
22*f4a2713aSLionel Sambuc SYNC_AFTER();
23*f4a2713aSLionel Sambuc @synchronized ([sem self]) {
24*f4a2713aSLionel Sambuc    SYNCH_BODY();
25*f4a2713aSLionel Sambuc    return;
26*f4a2713aSLionel Sambuc }
27*f4a2713aSLionel Sambuc}
28*f4a2713aSLionel Sambuc
29*f4a2713aSLionel Sambucvoid test_sync_with_implicit_finally() {
30*f4a2713aSLionel Sambuc    id foo;
31*f4a2713aSLionel Sambuc    @synchronized (foo) {
32*f4a2713aSLionel Sambuc        return; // The rewriter knows how to generate code for implicit finally
33*f4a2713aSLionel Sambuc    }
34*f4a2713aSLionel Sambuc}
35*f4a2713aSLionel Sambuc
36*f4a2713aSLionel Sambuc// rdar://14993814
37*f4a2713aSLionel Sambuc@interface NSObject @end
38*f4a2713aSLionel Sambuc
39*f4a2713aSLionel Sambuc@interface I : NSObject @end
40*f4a2713aSLionel Sambuc
41*f4a2713aSLionel Sambuc@implementation I
42*f4a2713aSLionel Sambuc+ (void) Meth {
43*f4a2713aSLionel Sambuc@synchronized(self) {
44*f4a2713aSLionel Sambuc}
45*f4a2713aSLionel Sambuc}
46*f4a2713aSLionel Sambuc@end
47