| 1 |
/* Test C23 unsequenced attribute: composite type on ?:. */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-std=c23 -pedantic-errors" } */ |
| 4 |
/* { dg-additional-sources "c23-attr-unsequenced-5-aux.c" } */ |
| 5 |
|
| 6 |
int f1 () [[unsequenced]]; |
| 7 |
int f2 (); |
| 8 |
int f3 (); |
| 9 |
int (*fp1) () [[unsequenced]] = f2; |
| 10 |
int (*fp2) () [[unsequenced]] = f3; |
| 11 |
extern void abort (); |
| 12 |
|
| 13 |
int |
| 14 |
foo (int x) |
| 15 |
{ |
| 16 |
return __builtin_has_attribute (*(x ? f1 : f3), unsequenced); |
| 17 |
} |
| 18 |
|
| 19 |
int |
| 20 |
bar (int x) |
| 21 |
{ |
| 22 |
return __builtin_has_attribute (*(x ? fp1 : fp2), unsequenced); |
| 23 |
} |
| 24 |
|
| 25 |
int |
| 26 |
baz (int x) |
| 27 |
{ |
| 28 |
return __builtin_has_attribute (*(x ? f3 : f1), unsequenced); |
| 29 |
} |
| 30 |
|
| 31 |
int |
| 32 |
qux (int x) |
| 33 |
{ |
| 34 |
return __builtin_has_attribute (*(x ? fp2 : fp1), unsequenced); |
| 35 |
} |
| 36 |
|
| 37 |
int |
| 38 |
main () |
| 39 |
{ |
| 40 |
if (!foo (0) || !bar (0) || !baz (0) || !qux (0)) |
| 41 |
abort (); |
| 42 |
if (!foo (1) || !bar (1) || !baz (1) || !qux (1)) |
| 43 |
abort (); |
| 44 |
} |