1 // RUN: %clangxx_tsan -O1 --std=c++11 %s -o %t && %deflake %run %t 2>&1 | FileCheck %s
2 #include "custom_mutex.h"
6 // Test that we detect the destruction of an in-use mutex when the
7 // thread annotations don't otherwise disable the check.
10 std::aligned_storage
<sizeof(Mutex
), alignof(Mutex
)>::type mu1_store
;
11 Mutex
* mu1
= reinterpret_cast<Mutex
*>(&mu1_store
);
12 new(&mu1_store
) Mutex(false, 0);
17 std::aligned_storage
<sizeof(Mutex
), alignof(Mutex
)>::type mu2_store
;
18 Mutex
* mu2
= reinterpret_cast<Mutex
*>(&mu2_store
);
20 Mutex(false, __tsan_mutex_not_static
, __tsan_mutex_not_static
);
25 fprintf(stderr
, "DONE\n");
29 // CHECK: WARNING: ThreadSanitizer: destroy of a locked mutex
30 // CHECK: main {{.*}}custom_mutex5.cpp:14
31 // CHECK: WARNING: ThreadSanitizer: destroy of a locked mutex
32 // CHECK: main {{.*}}custom_mutex5.cpp:22