1 /* Test whether the -Wcast-qual handles cv-qualified functions correctly.  */
2 /* { dg-do compile } */
3 /* { dg-options "-Wcast-qual" } */
4 
5 typedef int (intfn_t) (int);
6 typedef void (voidfn_t) (void);
7 
8 typedef const intfn_t *constfn_t;
9 typedef volatile voidfn_t *noreturnfn_t;
10 
11 intfn_t intfn;
12 const intfn_t constfn;
13 voidfn_t voidfn;
14 volatile voidfn_t noreturnfn;
15 
16 intfn_t *i1 = intfn;
17 intfn_t *i2 = (intfn_t *) intfn;
18 intfn_t *i3 = constfn;
19 intfn_t *i4 = (intfn_t *) constfn; /* { dg-bogus "discards qualifier" } */
20 
21 constfn_t p1 = intfn; /* { dg-warning "makes '__attribute__..const..' qualified function" } */
22 constfn_t p2 = (constfn_t) intfn; /* { dg-warning "adds '__attribute__..const..' qualifier" } */
23 constfn_t p3 = constfn;
24 constfn_t p4 = (constfn_t) constfn;
25 
26 voidfn_t *v1 = voidfn;
27 voidfn_t *v2 = (voidfn_t *) voidfn;
28 voidfn_t *v3 = noreturnfn;
29 voidfn_t *v4 = (voidfn_t *) noreturnfn; /* { dg-bogus "discards qualifier" } */
30 
31 noreturnfn_t n1 = voidfn; /* { dg-warning "makes '__attribute__..noreturn..' qualified function" } */
32 noreturnfn_t n2 = (noreturnfn_t) voidfn; /* { dg-warning "adds '__attribute__..noreturn..' qualifier" } */
33 noreturnfn_t n3 = noreturnfn;
34 noreturnfn_t n4 = (noreturnfn_t) noreturnfn;
35