| 1 |
/* Test for constant expressions: invalid null pointer constants in |
| 2 |
various contexts (make sure NOPs are not inappropriately |
| 3 |
stripped). */ |
| 4 |
/* Origin: Joseph Myers <[email protected]> */ |
| 5 |
/* { dg-do compile } */ |
| 6 |
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ |
| 7 |
|
| 8 |
void *p = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */ |
| 9 |
struct s { void *a; } q = { (__SIZE_TYPE__)(void *)0 }; /* { dg-error "without a cast|near initialization" } */ |
| 10 |
void * |
| 11 |
f (void) |
| 12 |
{ |
| 13 |
void *r; |
| 14 |
r = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */ |
| 15 |
return (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */ |
| 16 |
} |
| 17 |
void g (void *); /* { dg-message "but argument is of type" } */ |
| 18 |
void |
| 19 |
h (void) |
| 20 |
{ |
| 21 |
g ((__SIZE_TYPE__)(void *)0); /* { dg-error "without a cast" } */ |
| 22 |
} |
| 23 |
void g2 (int, void *); /* { dg-message "but argument is of type" } */ |
| 24 |
void |
| 25 |
h2 (void) |
| 26 |
{ |
| 27 |
g2 (0, (__SIZE_TYPE__)(void *)0); /* { dg-error "without a cast" } */ |
| 28 |
} |