aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/cast-qual-2.c
blob: 5fd2b854d61453f5b459e1317bb599cc0c46f034 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Test whether the -Wcast-qual handles cv-qualified functions correctly.  */
/* { dg-do compile } */
/* { dg-options "-Wcast-qual" } */

typedef int (intfn_t) (int);
typedef void (voidfn_t) (void);

typedef const intfn_t *constfn_t;
typedef volatile voidfn_t *noreturnfn_t;

intfn_t intfn;
const intfn_t constfn;
voidfn_t voidfn;
volatile voidfn_t noreturnfn;

intfn_t *i1 = intfn;
intfn_t *i2 = (intfn_t *) intfn;
intfn_t *i3 = constfn;
intfn_t *i4 = (intfn_t *) constfn; /* { dg-bogus "discards qualifier" } */

constfn_t p1 = intfn; /* { dg-warning "makes '__attribute__..const..' qualified function" } */
constfn_t p2 = (constfn_t) intfn; /* { dg-warning "adds '__attribute__..const..' qualifier" } */
constfn_t p3 = constfn;
constfn_t p4 = (constfn_t) constfn;

voidfn_t *v1 = voidfn;
voidfn_t *v2 = (voidfn_t *) voidfn;
voidfn_t *v3 = noreturnfn;
voidfn_t *v4 = (voidfn_t *) noreturnfn; /* { dg-bogus "discards qualifier" } */

noreturnfn_t n1 = voidfn; /* { dg-warning "makes '__attribute__..noreturn..' qualified function" } */
noreturnfn_t n2 = (noreturnfn_t) voidfn; /* { dg-warning "adds '__attribute__..noreturn..' qualifier" } */
noreturnfn_t n3 = noreturnfn;
noreturnfn_t n4 = (noreturnfn_t) noreturnfn;