aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-43.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-43.C')
-rw-r--r--gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-43.C31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-43.C b/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-43.C
new file mode 100644
index 000000000..36fcb1bc4
--- /dev/null
+++ b/gcc-4.4.0/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-43.C
@@ -0,0 +1,31 @@
+// Test lock canonicalization when populating the initial lock sets of a
+// function. It locks are properly canonicalized, the analysis should not
+// complained about a_ in function FooBar::GetA() is not protected.
+// 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 Foo {
+ public:
+ Mutex *mu_;
+};
+
+class FooBar {
+ public:
+ Foo *foo_;
+ int GetA() EXCLUSIVE_LOCKS_REQUIRED(foo_->mu_) { return a_; }
+ int a_ GUARDED_BY(foo_->mu_);
+};
+
+FooBar *fb;
+
+main()
+{
+ int x;
+ fb->foo_->mu_->Lock();
+ x = fb->GetA();
+ fb->foo_->mu_->Unlock();
+}