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
4typedef struct objc_object {
5    Class isa;
6} *id;
7
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}
28
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}
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
47