summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/tm/template-1.C
blob: cb6bb382fe3e0f1a2c4e4ed7a70c497e7a6e6bae (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
33
34
35
36
// { dg-do compile }
// { dg-options "-fgnu-tm -O -fdump-tree-tmmark" }

struct TrueFalse
{
  static bool v() { return true; }
};

int global;

template<typename T> int foo()
{
  __transaction_atomic { global += 2; }
  return __transaction_atomic (global + 1);
}

template<typename T> int bar() __transaction_atomic
{
  return global + 3;
}

template<typename T> void bar2() __transaction_atomic
{
  global += 4;
}

int f1()
{
  bar2<TrueFalse>();
  return foo<TrueFalse>() + bar<TrueFalse>();
}

/* 4 transactions overall, two of them write to global:  */
/* { dg-final { scan-tree-dump-times "ITM_RU4\\s*\\(&global" 4 "tmmark" } } */
/* { dg-final { scan-tree-dump-times "ITM_WU4\\s*\\(&global" 2 "tmmark" } } */
/* { dg-final { cleanup-tree-dump "tmmark" } } */