aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-55.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-55.C')
-rw-r--r--gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-55.C38
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-55.C b/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-55.C
new file mode 100644
index 000000000..10a12d43e
--- /dev/null
+++ b/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-55.C
@@ -0,0 +1,38 @@
+// Test the handling of the annotations with function parameters.
+// This is a good test case. (i.e. There should be no warning emitted by the
+// compiler.)
+// { dg-do compile }
+// { dg-options "-Wthread-safety -O" }
+
+#include "thread_annot_common.h"
+
+class Base {
+ private:
+ Mutex mu1_;
+
+ public:
+ Mutex *mutable_mu() LOCK_RETURNED(mu1_) { return &mu1_; }
+};
+
+class Foo {
+ public:
+ Mutex mu2_;
+ void Test1(Mutex* mu) const EXCLUSIVE_LOCKS_REQUIRED(mu, mu2_);
+ void Test2(Mutex* mu) const LOCKS_EXCLUDED(mu);
+};
+
+class Bar : public Base {
+ private:
+ Foo foo_;
+
+ public:
+ void Test3();
+};
+
+void Bar::Test3() {
+ MutexLock l(&foo_.mu2_);
+ mutable_mu()->Lock();
+ foo_.Test1(mutable_mu());
+ mutable_mu()->Unlock();
+ foo_.Test2(mutable_mu());
+}