Debian Codegraph @

gcc/testsuite/c-c++-common/Wcast-function-type.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-Wcast-function-type" } */
3 /* { dg-additional-options "-std=gnu17" { target c } } */
4
5 int f(long);
6
7 typedef int (f1)(long);
8 typedef int (f2)(void*);
9 #ifdef __cplusplus
10 typedef int (f3)(...);
11 typedef void (f4)(...);
12 #else
13 typedef int (f3)();
14 typedef void (f4)();
15 #endif
16 typedef void (f5)(void);
17
18 f1 *a;
19 f2 *b;
20 f3 *c;
21 f4 *d;
22 f5 *e;
23
24 void
25 foo (void)
26 {
27 a = (f1 *) f; /* { dg-bogus "incompatible function types" } */
28 b = (f2 *) f; /* { dg-warning "7:cast between incompatible function types" } */
29 c = (f3 *) f; /* { dg-bogus "incompatible function types" } */
30 d = (f4 *) f; /* { dg-warning "7:cast between incompatible function types" } */
31 e = (f5 *) f; /* { dg-bogus "incompatible function types" } */
32 }