annotate clang/test/SemaCXX/template-multiple-attr-propagation.cpp @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 %s -Wthread-safety-analysis -verify -fexceptions
anatofuz
parents:
diff changeset
2 // expected-no-diagnostics
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 class Mutex {
anatofuz
parents:
diff changeset
5 public:
anatofuz
parents:
diff changeset
6 void Lock() __attribute__((exclusive_lock_function()));
anatofuz
parents:
diff changeset
7 void Unlock() __attribute__((unlock_function()));
anatofuz
parents:
diff changeset
8 };
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 class A {
anatofuz
parents:
diff changeset
11 public:
anatofuz
parents:
diff changeset
12 Mutex mu1, mu2;
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 void foo() __attribute__((exclusive_locks_required(mu1))) __attribute__((exclusive_locks_required(mu2))) {}
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 template <class T>
anatofuz
parents:
diff changeset
17 void bar() __attribute__((exclusive_locks_required(mu1))) __attribute__((exclusive_locks_required(mu2))) {
anatofuz
parents:
diff changeset
18 foo();
anatofuz
parents:
diff changeset
19 }
anatofuz
parents:
diff changeset
20 };
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 void f() {
anatofuz
parents:
diff changeset
23 A a;
anatofuz
parents:
diff changeset
24 a.mu1.Lock();
anatofuz
parents:
diff changeset
25 a.mu2.Lock();
anatofuz
parents:
diff changeset
26 a.bar<int>();
anatofuz
parents:
diff changeset
27 a.mu2.Unlock();
anatofuz
parents:
diff changeset
28 a.mu1.Unlock();
anatofuz
parents:
diff changeset
29 }