1 // RUN: %clangxx_tsan %s -o %t -framework Foundation
2 // RUN: %run %t 2>&1 | FileCheck %s
4 #import <Foundation/Foundation.h>
7 fprintf(stderr, "start\n");
9 dispatch_queue_t background_q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
10 dispatch_queue_t main_q = dispatch_get_main_queue();
12 dispatch_async(background_q, ^{
13 __block long block_var = 0;
15 dispatch_sync(main_q, ^{
19 fprintf(stderr, "block_var = %ld\n", block_var);
21 dispatch_sync(dispatch_get_main_queue(), ^{
22 CFRunLoopStop(CFRunLoopGetCurrent());
27 fprintf(stderr, "done\n");
31 // CHECK: block_var = 42
33 // CHECK-NOT: WARNING: ThreadSanitizer
34 // CHECK-NOT: CHECK failed