aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-78.C
blob: 5055a924a24879f52c3c93d9c30b623efe64f133 (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
// Test the support to handle cloned methods.
// { dg-do compile }
// { dg-options "-O2 -Wthread-safety -fipa-sra" }

#include "thread_annot_common.h"

struct A {
  int *data_ PT_GUARDED_BY(mu_);
  mutable Mutex mu_;
  void Reset(void) EXCLUSIVE_LOCKS_REQUIRED(mu_) {
    delete data_;
  }
};

struct B {
  A a_;
  void TestFunc1();
  void TestFunc2();
};

void B::TestFunc1() {
  MutexLock l(&a_.mu_);
  a_.Reset();  // This call is an IPA-SRA clone candidate.
}

void B::TestFunc2() {
  a_.Reset();  // { dg-warning "Calling function 'Reset' requires lock" }
}