Home | History | Annotate | Download | only in lit_tests
      1 // RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
      2 #include <pthread.h>
      3 #include <stdio.h>
      4 #include <stddef.h>
      5 
      6 int GlobalData[10];
      7 
      8 void *Thread(void *a) {
      9   GlobalData[2] = 42;
     10   return 0;
     11 }
     12 
     13 int main() {
     14   fprintf(stderr, "addr=%p\n", GlobalData);
     15   pthread_t t;
     16   pthread_create(&t, 0, Thread, 0);
     17   GlobalData[2] = 43;
     18   pthread_join(t, 0);
     19 }
     20 
     21 // CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
     22 // CHECK: WARNING: ThreadSanitizer: data race
     23 // Requires llvm-symbolizer, so disabled for now.
     24 // CHECK0: Location is global 'GlobalData' of size 40 at [[ADDR]]
     25 // CHECK0:                            (global_race.cc.exe+0x[0-9,a-f]+)
     26