URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
298 |
jeremybenn |
/* Test null pointer constants: typedefs for void should be OK but not
|
2 |
|
|
qualified void. */
|
3 |
|
|
/* Origin: Joseph Myers <joseph@codesourcery.com> */
|
4 |
|
|
/* { dg-do compile } */
|
5 |
|
|
/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
|
6 |
|
|
|
7 |
|
|
typedef void V;
|
8 |
|
|
int *p;
|
9 |
|
|
long *q;
|
10 |
|
|
int j;
|
11 |
|
|
void (*fp)(void);
|
12 |
|
|
|
13 |
|
|
void
|
14 |
|
|
f (void)
|
15 |
|
|
{
|
16 |
|
|
/* (V *)0 is a null pointer constant, so the assignment should be
|
17 |
|
|
diagnosed. */
|
18 |
|
|
q = (j ? p : (V *)0); /* { dg-error "5:assignment from incompatible pointer type" } */
|
19 |
|
|
q = (j ? p : (void *)0); /* { dg-error "5:assignment from incompatible pointer type" } */
|
20 |
|
|
/* And this conversion should be valid. */
|
21 |
|
|
(void (*)(void))(V *)0;
|
22 |
|
|
(void (*)(void))(void *)0;
|
23 |
|
|
/* Pointers to qualified void are not valid null pointer
|
24 |
|
|
constants. */
|
25 |
|
|
fp = (const void *)0; /* { dg-error "6:ISO C forbids assignment between function pointer and 'void \\*'" } */
|
26 |
|
|
fp = (void *)0;
|
27 |
|
|
fp = (V *)0;
|
28 |
|
|
fp = 0;
|
29 |
|
|
fp == 0;
|
30 |
|
|
|
31 |
|
|
fp == (void *)0;
|
32 |
|
|
(void *)0 == fp;
|
33 |
|
|
fp == (V *)0;
|
34 |
|
|
(V *)0 == fp;
|
35 |
|
|
fp == (V *)1; /* { dg-error "6:ISO C forbids comparison of 'void \\*' with function pointer" } */
|
36 |
|
|
(V *)1 == fp; /* { dg-error "10:ISO C forbids comparison of 'void \\*' with function pointer" } */
|
37 |
|
|
fp == (const void *)0; /* { dg-error "6:ISO C forbids comparison of 'void \\*' with function pointer" } */
|
38 |
|
|
(const void *)0 == fp; /* { dg-error "19:ISO C forbids comparison of 'void \\*' with function pointer" } */
|
39 |
|
|
}
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.