| 1 |
/* Test zero with different types as null pointer constant: bug 112556. */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-std=c11 -pedantic-errors -Wno-pointer-compare" } */ |
| 4 |
|
| 5 |
enum e { ZERO }; |
| 6 |
|
| 7 |
void *p1 = 0; |
| 8 |
void *p2 = 0LL; |
| 9 |
void *p3 = (char) 0; |
| 10 |
void *p4 = 0UL; |
| 11 |
void *p5 = (_Bool) 0; |
| 12 |
void *p6 = (enum e) ZERO; |
| 13 |
|
| 14 |
void f (void *); |
| 15 |
|
| 16 |
void * |
| 17 |
g (void) |
| 18 |
{ |
| 19 |
p1 = 0; |
| 20 |
p2 = 0LL; |
| 21 |
p3 = (char) 0; |
| 22 |
p4 = 0UL; |
| 23 |
p5 = (_Bool) 0; |
| 24 |
p6 = (enum e) ZERO; |
| 25 |
f (0); |
| 26 |
f (0ULL); |
| 27 |
f (0L); |
| 28 |
f ((char) 0); |
| 29 |
f ((_Bool) 0); |
| 30 |
f ((enum e) ZERO); |
| 31 |
(1 ? p1 : 0); |
| 32 |
(1 ? p1 : 0L); |
| 33 |
(1 ? p1 : 0ULL); |
| 34 |
(1 ? p1 : (char) 0); |
| 35 |
(1 ? p1 : (_Bool) 0); |
| 36 |
(1 ? p1 : (enum e) 0); |
| 37 |
p1 == 0; |
| 38 |
p1 == 0LL; |
| 39 |
p1 == 0U; |
| 40 |
p1 == (char) 0; |
| 41 |
p1 == (_Bool) 0; |
| 42 |
p1 == (enum e) 0; |
| 43 |
p1 != 0; |
| 44 |
p1 != 0LL; |
| 45 |
p1 != 0U; |
| 46 |
p1 != (char) 0; |
| 47 |
p1 != (_Bool) 0; |
| 48 |
p1 != (enum e) 0; |
| 49 |
return 0; |
| 50 |
return 0UL; |
| 51 |
return 0LL; |
| 52 |
return (char) 0; |
| 53 |
return (_Bool) 0; |
| 54 |
return (enum e) 0; |
| 55 |
} |