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

source code of compiler-rt/test/tsan/ignore_free.cpp