diff options
author | Fangrui Song <maskray@google.com> | 2019-08-02 07:18:07 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-08-02 07:18:07 +0000 |
commit | 681afdf34bb16d1877e984d157dfd389a79a4256 (patch) | |
tree | 4e3f851ec5cfff68846a11843577ed58d4fdd430 /test/tsan/malloc_stack.cpp | |
parent | 871e3822d6679af8f7cfa763b65258e47f2d8d69 (diff) | |
download | compiler-rt-681afdf34bb16d1877e984d157dfd389a79a4256.tar.gz |
compiler-rt: Rename .cc file in test/tsan to .cpp
Like r367463, but for test/tsan.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@367656 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tsan/malloc_stack.cpp')
-rw-r--r-- | test/tsan/malloc_stack.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/tsan/malloc_stack.cpp b/test/tsan/malloc_stack.cpp new file mode 100644 index 000000000..f0c6f9354 --- /dev/null +++ b/test/tsan/malloc_stack.cpp @@ -0,0 +1,26 @@ +// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s +#include "test.h" + +_Atomic(int*) p; + +void *thr(void *a) { + barrier_wait(&barrier); + int *pp = __c11_atomic_load(&p, __ATOMIC_RELAXED); + *pp = 42; + return 0; +} + +int main() { + barrier_init(&barrier, 2); + pthread_t th; + pthread_create(&th, 0, thr, p); + __c11_atomic_store(&p, new int, __ATOMIC_RELAXED); + barrier_wait(&barrier); + pthread_join(th, 0); +} + +// CHECK: data race +// CHECK: Previous write +// CHECK: #0 operator new +// CHECK: Location is heap block +// CHECK: #0 operator new |