gcc/testsuite/g++.dg/tm/pr45940-2.C
raw| 1 | // { dg-do compile } |
| 2 | // { dg-options "-fgnu-tm -O1" } |
| 3 | |
| 4 | __attribute__((transaction_pure)) |
| 5 | inline int atomic_exchange_and_add(int dv ) |
| 6 | { |
| 7 | int r; |
| 8 | __asm__ ("" : "=r"(r)); |
| 9 | return r; |
| 10 | } |
| 11 | |
| 12 | class sp_counted_base |
| 13 | { |
| 14 | public: |
| 15 | __attribute__((transaction_safe)) |
| 16 | void release() |
| 17 | { |
| 18 | if( atomic_exchange_and_add(-1 ) == 1 ) |
| 19 | { |
| 20 | } |
| 21 | } |
| 22 | }; |
| 23 | |
| 24 | sp_counted_base *base; |
| 25 | |
| 26 | void here(){ |
| 27 | __transaction_atomic { |
| 28 | base->release(); |
| 29 | } |
| 30 | } |