| 1 |
/* PR c/25801 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-std=c99" } */ |
| 4 |
|
| 5 |
int (*a)[]; |
| 6 |
struct S *s; |
| 7 |
union U *u; |
| 8 |
enum E *e; |
| 9 |
|
| 10 |
void |
| 11 |
f (void) |
| 12 |
{ |
| 13 |
a++; /* { dg-error "increment of pointer to an incomplete type" } */ |
| 14 |
++a; /* { dg-error "increment of pointer to an incomplete type" } */ |
| 15 |
a--; /* { dg-error "decrement of pointer to an incomplete type" } */ |
| 16 |
--a; /* { dg-error "decrement of pointer to an incomplete type" } */ |
| 17 |
a += 1; /* { dg-error "invalid use of array with unspecified bounds" } */ |
| 18 |
a -= 1; /* { dg-error "invalid use of array with unspecified bounds" } */ |
| 19 |
a - a; /* { dg-error "arithmetic on pointer to an incomplete type" } */ |
| 20 |
|
| 21 |
s++; /* { dg-error "increment of pointer to an incomplete type" } */ |
| 22 |
++s; /* { dg-error "increment of pointer to an incomplete type" } */ |
| 23 |
s--; /* { dg-error "decrement of pointer to an incomplete type" } */ |
| 24 |
--s; /* { dg-error "decrement of pointer to an incomplete type" } */ |
| 25 |
s += 1; /* { dg-error "invalid use of undefined type" } */ |
| 26 |
s -= 1; /* { dg-error "invalid use of undefined type" } */ |
| 27 |
s - s; /* { dg-error "arithmetic on pointer to an incomplete type" } */ |
| 28 |
|
| 29 |
u++; /* { dg-error "increment of pointer to an incomplete type" } */ |
| 30 |
++u; /* { dg-error "increment of pointer to an incomplete type" } */ |
| 31 |
u--; /* { dg-error "decrement of pointer to an incomplete type" } */ |
| 32 |
--u; /* { dg-error "decrement of pointer to an incomplete type" } */ |
| 33 |
u += 1; /* { dg-error "invalid use of undefined type" } */ |
| 34 |
u -= 1; /* { dg-error "invalid use of undefined type" } */ |
| 35 |
u - u; /* { dg-error "arithmetic on pointer to an incomplete type" } */ |
| 36 |
|
| 37 |
e++; /* { dg-error "increment of pointer to an incomplete type" } */ |
| 38 |
++e; /* { dg-error "increment of pointer to an incomplete type" } */ |
| 39 |
e--; /* { dg-error "decrement of pointer to an incomplete type" } */ |
| 40 |
--e; /* { dg-error "decrement of pointer to an incomplete type" } */ |
| 41 |
e += 1; /* { dg-error "invalid use of undefined type" } */ |
| 42 |
e -= 1; /* { dg-error "invalid use of undefined type" } */ |
| 43 |
e - e; /* { dg-error "arithmetic on pointer to an incomplete type" } */ |
| 44 |
} |