1// RUN: %clang_tsan %s -o %t -framework Foundation
2// RUN: %run %t 2>&1
3
4#import <Foundation/Foundation.h>
5
6long global;
7
8int main() {
9  NSLog(@"Hello world.");
10
11  global = 42;
12  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
13    global = 43;
14
15    dispatch_sync(dispatch_get_main_queue(), ^{
16      CFRunLoopStop(CFRunLoopGetCurrent());
17    });
18  });
19
20  CFRunLoopRun();
21  NSLog(@"Done.");
22}
23
24// CHECK: Hello world.
25// CHECK: Done.
26// CHECK-NOT: WARNING: ThreadSanitizer
27