| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fgnu-tm" } */ |
| 3 |
|
| 4 |
void ts(void) __attribute__((transaction_safe)); |
| 5 |
void tp(void) __attribute__((transaction_pure)); |
| 6 |
void tc(void) __attribute__((transaction_callable)); |
| 7 |
void ti(void) __attribute__((transaction_unsafe)); |
| 8 |
void tm(void) __attribute__((transaction_may_cancel_outer)); |
| 9 |
void tu(void); |
| 10 |
int fc(int) __attribute__((const)); |
| 11 |
|
| 12 |
typedef void (*Fs) (void) __attribute__((transaction_safe)); |
| 13 |
typedef void (*Fc) (void) __attribute__((transaction_callable)); |
| 14 |
typedef void (*Fi) (void) __attribute__((transaction_unsafe)); |
| 15 |
typedef void (*Fm) (void) __attribute__((transaction_may_cancel_outer)); |
| 16 |
extern Fs ps; |
| 17 |
extern Fc pc; |
| 18 |
extern Fi pi; |
| 19 |
extern Fm pm; |
| 20 |
extern void (*pu)(void); |
| 21 |
|
| 22 |
int __attribute__((transaction_safe)) |
| 23 |
foo(void) |
| 24 |
{ |
| 25 |
int i; |
| 26 |
|
| 27 |
ts(); |
| 28 |
tp(); |
| 29 |
tc(); /* { dg-error "unsafe function call" } */ |
| 30 |
ti(); /* { dg-error "unsafe function call" } */ |
| 31 |
|
| 32 |
/* ??? Direct function calls without markups are handled later |
| 33 |
than pass_diagnose_tm_blocks, which means we'll exit with |
| 34 |
errors before getting there. This test moved to safe-3.c. */ |
| 35 |
/* tu(); */ |
| 36 |
|
| 37 |
(*ps)(); |
| 38 |
(*pc)(); /* { dg-error "unsafe indirect function call" } */ |
| 39 |
(*pi)(); /* { dg-error "unsafe indirect function call" } */ |
| 40 |
(*pu)(); /* { dg-error "unsafe indirect function call" } */ |
| 41 |
|
| 42 |
asm(""); /* { dg-error "'asm' not allowed" } */ |
| 43 |
asm("" : "=g"(i)); /* { dg-error "'asm' not allowed" } */ |
| 44 |
|
| 45 |
return fc(i); |
| 46 |
} |
| 47 |
|
| 48 |
int __attribute__((transaction_may_cancel_outer)) |
| 49 |
bar(void) |
| 50 |
{ |
| 51 |
int i; |
| 52 |
|
| 53 |
ts(); |
| 54 |
tp(); |
| 55 |
tc(); /* { dg-error "unsafe function call" } */ |
| 56 |
ti(); /* { dg-error "unsafe function call" } */ |
| 57 |
tm(); |
| 58 |
|
| 59 |
(*ps)(); |
| 60 |
(*pc)(); /* { dg-error "unsafe indirect function call" } */ |
| 61 |
(*pi)(); /* { dg-error "unsafe indirect function call" } */ |
| 62 |
(*pm)(); |
| 63 |
(*pu)(); /* { dg-error "unsafe indirect function call" } */ |
| 64 |
|
| 65 |
asm(""); /* { dg-error "'asm' not allowed" } */ |
| 66 |
asm("" : "=g"(i)); /* { dg-error "'asm' not allowed" } */ |
| 67 |
|
| 68 |
return fc(i); |
| 69 |
} |