llvm-project
29 строк · 596.0 Байт
1// RUN: echo "race_top:TopFunction" > %t.supp
2// RUN: %clangxx_tsan -O1 %s -o %t
3// RUN: %env_tsan_opts=suppressions='%t.supp' %run %t 2>&1 | FileCheck %s
4// RUN: rm %t.supp
5#include "test.h"
6
7int Global;
8
9__attribute__((noinline)) void TopFunction(int *p) {
10*p = 1;
11}
12
13void *Thread(void *x) {
14barrier_wait(&barrier);
15TopFunction(&Global);
16return 0;
17}
18
19int main() {
20barrier_init(&barrier, 2);
21pthread_t t;
22pthread_create(&t, 0, Thread, 0);
23Global--;
24barrier_wait(&barrier);
25pthread_join(t, 0);
26fprintf(stderr, "DONE\n");
27}
28
29// CHECK-NOT: WARNING: ThreadSanitizer: data race
30