1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
2 #include "test.h"
3 
Thread(void * a)4 void *Thread(void *a) {
5   barrier_wait(&barrier);
6   *(int*)a = 43;
7   return 0;
8 }
9 
main()10 int main() {
11   barrier_init(&barrier, 2);
12   static __thread int Var = 42;
13   pthread_t t;
14   pthread_create(&t, 0, Thread, &Var);
15   Var = 43;
16   barrier_wait(&barrier);
17   pthread_join(t, 0);
18 }
19 
20 // CHECK: WARNING: ThreadSanitizer: data race
21 // CHECK-Linux:   Location is TLS of main thread.
22 // CHECK-FreeBSD:   Location is TLS of main thread.
23 // CHECK-NetBSD:   Location is TLS of main thread.
24 // CHECK-Darwin:   Location is heap block of size 4
25