1 // { dg-do compile } 2 // { dg-options "-fgnu-tm -O -fdump-tree-tmmark" } 3 4 struct TrueFalse 5 { vTrueFalse6 static bool v() { return true; } 7 }; 8 9 int global; 10 foo()11template<typename T> int foo() 12 { 13 __transaction_atomic { global += 2; } 14 return __transaction_atomic (global + 1); 15 } 16 bar()17template<typename T> int bar() __transaction_atomic 18 { 19 return global + 3; 20 } 21 bar2()22template<typename T> void bar2() __transaction_atomic 23 { 24 global += 4; 25 } 26 f1()27int f1() 28 { 29 bar2<TrueFalse>(); 30 return foo<TrueFalse>() + bar<TrueFalse>(); 31 } 32 33 /* 4 transactions overall, two of them write to global: */ 34 /* { dg-final { scan-tree-dump-times "ITM_RU4\\s*\\(&global" 4 "tmmark" } } */ 35 /* { dg-final { scan-tree-dump-times "ITM_WU4\\s*\\(&global" 2 "tmmark" } } */ 36