]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/c-c++-common/tm/safe-3.c
Merge from transactional-memory branch.
[thirdparty/gcc.git] / gcc / testsuite / c-c++-common / tm / safe-3.c
1 /* { dg-do compile } */
2 /* { dg-options "-fgnu-tm" } */
3
4 void f_extern (void);
5 void f_first (void);
6 void f_later (void);
7
8 extern int x;
9
10 void f_first (void) { x++; }
11
12 void __attribute__((transaction_safe))
13 test_safe (void)
14 {
15 f_extern (); /* { dg-error "unsafe function call" } */
16 f_first ();
17 f_later ();
18 }
19
20 void __attribute__((transaction_may_cancel_outer))
21 test_mco (void)
22 {
23 f_extern (); /* { dg-error "unsafe function call" } */
24 f_first ();
25 f_later ();
26 }
27
28 void
29 test_atomic (void)
30 {
31 __transaction_atomic {
32 f_extern (); /* { dg-error "unsafe function call" } */
33 f_first ();
34 f_later ();
35 }
36 __transaction_relaxed {
37 f_extern ();
38 f_first ();
39 f_later ();
40 }
41 __transaction_atomic [[outer]] {
42 f_extern (); /* { dg-error "unsafe function call" } */
43 f_first ();
44 f_later ();
45 }
46 }
47
48 void f_later () { f_first(); test_safe(); }