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