1 /* Test operation of -Wbad-function-cast. Bug 6980 complained of the
2 wording of the diagnostic. */
3 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
4 /* { dg-do compile } */
5 /* { dg-options "-Wbad-function-cast" } */
13 _Complex
double cf(void);
14 enum e
{ E1
} ef(void);
22 /* Casts to void types are always OK. */
27 /* Casts to the same type or similar types are OK. */
38 /* Casts to types with different TREE_CODE (which is how this
39 warning has been defined) are not OK, except for casts to void
41 (float)if1(); /* { dg-warning "cast from function call of type 'int' to non-matching type 'float'" } */
42 (double)if2(); /* { dg-warning "cast from function call of type 'char' to non-matching type 'double'" } */
43 (_Bool
)if3(); /* { dg-warning "cast from function call of type 'long int' to non-matching type '_Bool'" } */
44 (int)rf1(); /* { dg-warning "cast from function call of type 'float' to non-matching type 'int'" } */
45 (long)rf2(); /* { dg-warning "cast from function call of type 'double' to non-matching type 'long int'" } */
46 (double)cf(); /* { dg-warning "cast from function call of type 'complex double' to non-matching type 'double'" } */
47 (int)ef(); /* { dg-warning "cast from function call of type 'enum e' to non-matching type 'int'" } */
48 (int)bf(); /* { dg-warning "cast from function call of type '_Bool' to non-matching type 'int'" } */
49 (__SIZE_TYPE__
)pf1(); /* { dg-warning "cast from function call of type 'char \\*' to non-matching type '\[^\\n\]*'" } */
50 (__PTRDIFF_TYPE__
)pf2(); /* { dg-warning "cast from function call of type 'int \\*' to non-matching type '\[^\\n\]*'" } */