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 foo()14 void foo() __attribute__((exclusive_locks_required(mu1))) __attribute__((exclusive_locks_required(mu2))) {} 15 16 template <class T> bar()17 void bar() __attribute__((exclusive_locks_required(mu1))) __attribute__((exclusive_locks_required(mu2))) { 18 foo(); 19 } 20 }; 21 f()22void 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 } 30