| 1 |
/* Test for C99 declarations in for loops. Test constraints are diagnosed with |
| 2 |
-Wc11-c23-compat for C23: struct and union tags can't be declared there |
| 3 |
(affirmed in response to DR#277). Based on c99-fordecl-3.c. */ |
| 4 |
/* { dg-do compile } */ |
| 5 |
/* { dg-options "-std=c23 -pedantic-errors -Wc11-c23-compat" } */ |
| 6 |
|
| 7 |
void |
| 8 |
foo (void) |
| 9 |
{ |
| 10 |
for (struct s { int p; } *p = 0; ;) /* { dg-warning "'struct s' declared in 'for' loop initial declaration" } */ |
| 11 |
; |
| 12 |
for (union u { int p; } *p = 0; ;) /* { dg-warning "'union u' declared in 'for' loop initial declaration" } */ |
| 13 |
; |
| 14 |
} |