aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-67.C
blob: be228ec20179f9cc6e9d5f34f8c06a9f8222fd4e (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 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 }