diff options
Diffstat (limited to 'gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-62.C')
-rw-r--r-- | gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-62.C | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-62.C b/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-62.C new file mode 100644 index 000000000..95f318699 --- /dev/null +++ b/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-62.C @@ -0,0 +1,18 @@ +// Test the support for allowing non-const but non-modifying overloaded +// operator 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 <vector> +#include "thread_annot_common.h" + +Mutex mu; + +std::vector<int> counts GUARDED_BY(mu); + +int foo(int key) { + ReaderMutexLock l(&mu); + return counts[key]; +} |