]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/tsan/tls_race.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / tsan / tls_race.cc
CommitLineData
92a42be0
SL
1// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2#include "test.h"
1a4d82fc
JJ
3
4void *Thread(void *a) {
92a42be0 5 barrier_wait(&barrier);
1a4d82fc
JJ
6 *(int*)a = 43;
7 return 0;
8}
9
10int main() {
92a42be0 11 barrier_init(&barrier, 2);
1a4d82fc
JJ
12 static __thread int Var = 42;
13 pthread_t t;
14 pthread_create(&t, 0, Thread, &Var);
15 Var = 43;
92a42be0 16 barrier_wait(&barrier);
1a4d82fc
JJ
17 pthread_join(t, 0);
18}
19
20// CHECK: WARNING: ThreadSanitizer: data race
21// CHECK: Location is TLS of main thread.