aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/tm/pr45940-2.C
blob: ab10c34baaac997aa963f3470c55fa659ceaac3a (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
// { dg-do compile }
// { dg-options "-fgnu-tm -O1" }

__attribute__((transaction_pure))
inline int atomic_exchange_and_add(int dv )
{
    int r;
    __asm__ ("" : "=r"(r));
    return r;
}

class sp_counted_base
{
public:
    __attribute__((transaction_safe))
    void release()
    {
	if( atomic_exchange_and_add(-1 ) == 1 )
	{
	}
    }
};

sp_counted_base *base;

void here(){
  __transaction_atomic {
    base->release();
  }
}