blob: e89533930388e149ce7aae8da106d3d6dcc7773b [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 Jahanian55261af2012-03-19 18:11:32 +00002// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
3
4typedef struct objc_class *Class;
5typedef struct objc_object {
6 Class isa;
7} *id;
Fariborz Jahanian542125f2012-03-16 21:33:16 +00008
9void *sel_registerName(const char *);
10
11id SYNCH_EXPR();
12void SYNCH_BODY();
13void SYNCH_BEFORE();
14void SYNC_AFTER();
15
16void foo(id sem)
17{
18 SYNCH_BEFORE();
19 @synchronized (SYNCH_EXPR()) {
20 SYNCH_BODY();
21 return;
22 }
23 SYNC_AFTER();
24 @synchronized ([sem self]) {
25 SYNCH_BODY();
26 return;
27 }
28}
Fariborz Jahanian22e2f852012-03-17 17:46:02 +000029
30void test_sync_with_implicit_finally() {
31 id foo;
32 @synchronized (foo) {
33 return; // The rewriter knows how to generate code for implicit finally
34 }
35}