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