aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-66.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-66.C')
-rw-r--r--gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-66.C35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-66.C b/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-66.C
new file mode 100644
index 000000000..c341973e7
--- /dev/null
+++ b/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-66.C
@@ -0,0 +1,35 @@
+// Test annotations on out-of-line definitions of member functions where the
+// annotations refer to locks that are also data members in the class.
+// 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"
+
+Mutex mu;
+
+class Foo {
+ public:
+ int method1(int i);
+ int data GUARDED_BY(mu1);
+ Mutex *mu1;
+ Mutex *mu2;
+};
+
+int Foo::method1(int i) SHARED_LOCKS_REQUIRED(mu1, mu, mu2)
+{
+ return data + i;
+}
+
+main()
+{
+ Foo a;
+
+ MutexLock l(a.mu2);
+ a.mu1->Lock();
+ mu.Lock();
+ a.method1(1);
+ mu.Unlock();
+ a.mu1->Unlock();
+}