aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-58.C
blob: 858e635582fb3824b6f96094ddd5bf63c4382f2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Test handling of arguments passed to reference parameters.
// { dg-do compile }
// { dg-options "-Wthread-safety -O" }

#include <string>
#include "thread_annot_common.h"

class Base {
 public:
  Base() {}
 protected:
  Mutex* mutex() const LOCK_RETURNED(mutex_) { return &mutex_; }
 private:
  mutable Mutex mutex_;
};

class Subclass : public Base {
 public:
  Subclass() {}

  void ClearValue() { SetValueLocked(0); }
  std::string GetValue() const;

 private:
  void SetValueLocked(std::string value) { value_ = value; }

  std::string value_ GUARDED_BY(mutex_);
};

std::string Subclass::GetValue() const {
  return value_; // { dg-warning "Reading variable 'value_' requires lock" }
}