aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-50.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-50.C')
-rw-r--r--gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-50.C22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-50.C b/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-50.C
new file mode 100644
index 000000000..e1e24c18e
--- /dev/null
+++ b/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-50.C
@@ -0,0 +1,22 @@
+// Test the support for allowing non-const but non-modifying methods to be
+// protected by reader locks.
+// 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 <map>
+#include "thread_annot_common.h"
+
+typedef std::map<int, int> MyMapType;
+
+Mutex mu;
+MyMapType MyMap GUARDED_BY(mu);
+
+int foo(int key) {
+ ReaderMutexLock l(&mu);
+ MyMapType::const_iterator iter = MyMap.find(key);
+ if (iter != MyMap.end()) {
+ return iter->second;
+ }
+}