| 1 |
/* Test C23 auto. Valid code, execution tests. Based on auto-type-1.c. */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-std=c23 -pedantic-errors" } */ |
| 4 |
|
| 5 |
extern void abort (void); |
| 6 |
extern void exit (int); |
| 7 |
|
| 8 |
auto i = 1; |
| 9 |
extern int i; |
| 10 |
auto c = (char) 1; |
| 11 |
extern char c; |
| 12 |
static auto u = 10U; |
| 13 |
extern unsigned int u; |
| 14 |
const auto ll = 1LL; |
| 15 |
extern const long long ll; |
| 16 |
|
| 17 |
int |
| 18 |
main (void) |
| 19 |
{ |
| 20 |
if (i != 1 || c != 1 || u != 10U) |
| 21 |
abort (); |
| 22 |
auto ai = i; |
| 23 |
int *aip = &ai; |
| 24 |
if (ai != 1) |
| 25 |
abort (); |
| 26 |
auto p = (int (*) [++i]) 0; |
| 27 |
if (i != 2) |
| 28 |
abort (); |
| 29 |
if (sizeof (*p) != 2 * sizeof (int)) |
| 30 |
abort (); |
| 31 |
int vla[u][u]; |
| 32 |
int (*vp)[u] = &vla[0]; |
| 33 |
auto vpp = ++vp; |
| 34 |
if (vp != &vla[1]) |
| 35 |
abort (); |
| 36 |
exit (0); |
| 37 |
} |