150
|
1 // RUN: %clang_cc1 %s -Wthread-safety-analysis -verify -fexceptions
|
|
2 // expected-no-diagnostics
|
|
3
|
|
4 class Mutex {
|
|
5 public:
|
|
6 void Lock() __attribute__((exclusive_lock_function()));
|
|
7 void Unlock() __attribute__((unlock_function()));
|
|
8 };
|
|
9
|
|
10 class A {
|
|
11 public:
|
|
12 Mutex mu1, mu2;
|
|
13
|
|
14 void foo() __attribute__((exclusive_locks_required(mu1))) __attribute__((exclusive_locks_required(mu2))) {}
|
|
15
|
|
16 template <class T>
|
|
17 void bar() __attribute__((exclusive_locks_required(mu1))) __attribute__((exclusive_locks_required(mu2))) {
|
|
18 foo();
|
|
19 }
|
|
20 };
|
|
21
|
|
22 void f() {
|
|
23 A a;
|
|
24 a.mu1.Lock();
|
|
25 a.mu2.Lock();
|
|
26 a.bar<int>();
|
|
27 a.mu2.Unlock();
|
|
28 a.mu1.Unlock();
|
|
29 }
|