1 /* Conversions between function and object pointers are not permitted
2 in any version of ISO C, even with casts, except for the special
3 case of converting a null pointer constant to function pointer
4 type. Likewise, comparisons between function and object pointers
5 are not permitted. PR c/11234. */
6 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
7 /* { dg-do compile } */
8 /* { dg-options "-pedantic" } */
12 void *v1
= f
; /* { dg-warning "12:pointer" "bad conversion" } */
13 void *v2
= &f
; /* { dg-warning "12:pointer" "bad conversion" } */
14 void *v3
= (void *)f
; /* { dg-warning "12:pointer" "bad conversion" } */
15 void *v4
= (void *)&f
; /* { dg-warning "12:pointer" "bad conversion" } */
17 char *c1
= f
; /* { dg-warning "12:pointer" "bad conversion" } */
18 char *c2
= &f
; /* { dg-warning "12:pointer" "bad conversion" } */
19 char *c3
= (char *)f
; /* { dg-warning "12:pointer" "bad conversion" } */
20 char *c4
= (char *)&f
; /* { dg-warning "12:pointer" "bad conversion" } */
28 v5
= f
; /* { dg-warning "6:pointer" "bad conversion" } */
29 v5
= &f
; /* { dg-warning "6:pointer" "bad conversion" } */
30 v5
= (void *)f
; /* { dg-warning "8:pointer" "bad conversion" } */
31 v5
= (void *)&f
; /* { dg-warning "8:pointer" "bad conversion" } */
32 c5
= f
; /* { dg-warning "6:pointer" "bad conversion" } */
33 c5
= &f
; /* { dg-warning "6:pointer" "bad conversion" } */
34 c5
= (char *)f
; /* { dg-warning "8:pointer" "bad conversion" } */
35 c5
= (char *)&f
; /* { dg-warning "8:pointer" "bad conversion" } */
36 fp
= v5
; /* { dg-warning "6:pointer" "bad conversion" } */
37 fp
= c5
; /* { dg-warning "6:pointer" "bad conversion" } */
38 fp
= (void (*)(void))v5
; /* { dg-warning "8:pointer" "bad conversion" } */
39 fp
= (void (*)(void))c5
; /* { dg-warning "8:pointer" "bad conversion" } */
40 (a
? f
: v3
); /* { dg-warning "10:pointer" "bad conversion" } */
41 (a
? v2
: fp
); /* { dg-warning "11:pointer" "bad conversion" } */
42 /* The following are OK. */
46 fp
= (void (*)(void))0;
47 fp
= (void (*)(void))(void *)0;
54 /* The following are OK. */
55 void (*fp2
)(void) = 0;
56 void (*fp3
)(void) = (void *)0;