1 // RUN: %clangxx_tsan %s -o %t -framework Foundation -fobjc-arc
2 // RUN: %run %t 2>&1 | FileCheck %s
4 #import <Foundation/Foundation.h>
6 NSString *tagged_string = nil;
8 @interface MyClass : NSObject {
11 @property(nonatomic, readonly) long value;
14 dispatch_group_t group;
16 @implementation MyClass
19 dispatch_queue_t q = dispatch_queue_create(NULL, NULL);
20 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
21 for (int i = 0; i < 10; i++) {
23 @synchronized(tagged_string) {
32 @synchronized(tagged_string) {
38 dispatch_group_leave(group);
44 tagged_string = [NSString stringWithFormat:@"%s", "abc"];
45 uintptr_t tagged_string_bits = (uintptr_t)tagged_string;
46 assert((tagged_string_bits & 0x8000000000000001ull) != 0);
47 group = dispatch_group_create();
49 for (int j = 0; j < 100; ++j) {
50 dispatch_group_enter(group);
51 MyClass *obj = [[MyClass alloc] init];
57 dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
58 NSLog(@"Hello world");
62 // CHECK-NOT: WARNING: ThreadSanitizer