Debian Codegraph @

clang/test/Analysis/thread-safety-handle-parenthesis.cpp

raw
1 // RUN: %clang_cc1 -verify -fsyntax-only -Wthread-safety %s
2
3 struct __attribute__((lockable)) Lock {};
4
5 void sink_protected(int);
6
7 struct Baz {
8 public:
9 Lock lock_;
10 int protected_num_ __attribute__((guarded_by(lock_))) = 1;
11 };
12
13 void paren_test() {
14 Baz baz;
15 int& n = baz.protected_num_;
16 sink_protected(n); // expected-warning{{reading variable 'protected_num_' requires holding mutex 'baz.lock_'}}
17 int& n2 = (baz.protected_num_);
18 sink_protected(n2); // expected-warning{{reading variable 'protected_num_' requires holding mutex 'baz.lock_'}}
19 }