1// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2#include "test.h"
3
4int Global;
5pthread_mutex_t Mutex = PTHREAD_MUTEX_INITIALIZER;
6
7void *Thread(void *x) {
8 AnnotateIgnoreSyncBegin(f: 0, l: 0);
9 pthread_mutex_lock(mutex: &Mutex);
10 Global++;
11 pthread_mutex_unlock(mutex: &Mutex);
12 AnnotateIgnoreSyncEnd(f: 0, l: 0);
13 return 0;
14}
15
16int main() {
17 pthread_t t;
18 pthread_create(newthread: &t, attr: 0, start_routine: Thread, arg: 0);
19 pthread_mutex_lock(mutex: &Mutex);
20 Global++;
21 pthread_mutex_unlock(mutex: &Mutex);
22 pthread_join(th: t, thread_return: 0);
23}
24
25// CHECK: WARNING: ThreadSanitizer: data race
26
27

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