1 // RUN: %clang_tsan -O1 %s -o %t && %env_tsan_opts=halt_on_error=1 %deflake %run %t | FileCheck %s 2 #include "test.h" 3 4 int X; 5 Thread(void * x)6void *Thread(void *x) { 7 barrier_wait(&barrier); 8 X = 42; 9 return 0; 10 } 11 main()12int main() { 13 barrier_init(&barrier, 2); 14 fprintf(stderr, "BEFORE\n"); 15 pthread_t t; 16 pthread_create(&t, 0, Thread, 0); 17 X = 43; 18 barrier_wait(&barrier); 19 pthread_join(t, 0); 20 fprintf(stderr, "AFTER\n"); 21 return 0; 22 } 23 24 // CHECK: BEFORE 25 // CHECK: WARNING: ThreadSanitizer: data race 26 // CHECK-NOT: AFTER 27 28