Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 1 | // RUN: echo "race_top:TopFunction" > %t.supp |
| 2 | // RUN: %clangxx_tsan -O1 %s -o %t |
| 3 | // RUN: %env_tsan_opts=suppressions='%t.supp' %deflake %run %t 2>&1 | FileCheck %s |
| 4 | // RUN: rm %t.supp |
| 5 | #include "test.h" |
| 6 | |
| 7 | int Global; |
| 8 | |
| 9 | void AnotherFunction(int *p) { |
| 10 | *p = 1; |
| 11 | } |
| 12 | |
| 13 | void TopFunction(int *p) { |
| 14 | AnotherFunction(p); |
| 15 | } |
| 16 | |
| 17 | void *Thread(void *x) { |
| 18 | barrier_wait(&barrier); |
| 19 | TopFunction(&Global); |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | int main() { |
| 24 | barrier_init(&barrier, 2); |
| 25 | pthread_t t; |
| 26 | pthread_create(&t, 0, Thread, 0); |
| 27 | Global--; |
| 28 | barrier_wait(&barrier); |
| 29 | pthread_join(t, 0); |
| 30 | } |
| 31 | |
| 32 | // CHECK: WARNING: ThreadSanitizer: data race |