1 // RUN: %clang_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not='ThreadSanitizer'
4 #include <dispatch/dispatch.h>
10 int main(int argc
, const char *argv
[]) {
11 fprintf(stderr
, "Hello world.\n");
13 dispatch_queue_t q1
= dispatch_queue_create("queue1", NULL
);
14 dispatch_queue_t q2
= dispatch_queue_create("queue2", NULL
);
15 dispatch_group_t g
= dispatch_group_create();
31 dispatch_group_enter(g
);
32 dispatch_async(q1
,^{ my_global
++; });
33 dispatch_async(q1
,^{ my_global
++; });
34 dispatch_async(q1
,^{ my_global
++; dispatch_group_leave(g
); });
39 dispatch_group_wait(g
, DISPATCH_TIME_FOREVER
);
41 fprintf(stderr
, "Done.\n");
45 // CHECK: Hello world.