brintos

brintos / llvm-project-archived public Read only

0
0
Text · 540 B · 7a129fb Raw
27 lines · cpp
1// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s2#include "test.h"3 4int Global;5pthread_mutex_t Mutex = PTHREAD_MUTEX_INITIALIZER;6 7void *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 16int 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 race26 27