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