• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
8int main() {
9    NSLog(@"Hello world.");
10
11    global = 42;
12
13    dispatch_semaphore_t sem = dispatch_semaphore_create(0);
14    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
15
16        global = 43;
17        dispatch_semaphore_signal(sem);
18    });
19
20    dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
21    global = 44;
22
23    NSLog(@"Done.");
24    return 0;
25}
26
27// CHECK: Hello world.
28// CHECK: Done.
29// CHECK-NOT: WARNING: ThreadSanitizer
30