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