aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-67.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-67.C')
-rw-r--r--gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-67.C32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-67.C b/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-67.C
new file mode 100644
index 000000000..be228ec20
--- /dev/null
+++ b/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-67.C
@@ -0,0 +1,32 @@
+// Test annotations on out-of-line definitions of member functions where the
+// annotations refer to locks that are also data members in the class.
+// { 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, mu3)
+{
+ return data + i;
+}
+
+main()
+{
+ Foo a;
+
+ a.method1(1); // { dg-warning "Calling function 'method1' requires lock" }
+}
+
+// { dg-warning "Calling function 'method1' requires lock 'mu'" { target *-*-* } 27 }
+// { dg-warning "Calling function 'method1' requires lock 'a.mu2'" { target *-*-* } 27 }
+// { dg-warning "Calling function 'method1' requires lock 'mu3'" { target *-*-* } 27 }