1// RUN: %clangxx_tsan %s -o %t -framework Foundation -fobjc-arc
2// RUN: %run %t 2>&1 | FileCheck %s
3
4#import <Foundation/Foundation.h>
5
6int main() {
7 @autoreleasepool {
8 NSObject* obj1 = [NSObject new];
9 NSObject* obj2 = [NSObject new];
10
11 @synchronized(obj1) {
12 @synchronized(obj1) {
13 NSLog(@"nested 1-1");
14// CHECK: nested 1-1
15 }
16 }
17
18 @synchronized(obj1) {
19 @synchronized(obj2) {
20 @synchronized(obj1) {
21 @synchronized(obj2) {
22 NSLog(@"nested 1-2-1-2");
23// CHECK: nested 1-2-1-2
24 }
25 }
26 }
27 }
28
29 }
30
31 NSLog(@"PASS");
32// CHECK-NOT: ThreadSanitizer
33// CHECK: PASS
34 return 0;
35}
36

source code of compiler-rt/test/tsan/Darwin/objc-synchronize-nested-recursive.mm