| 1 |
/* PR c/61162 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-fpermissive -Wc++-compat -Wpointer-sign -Wpedantic" } */ |
| 4 |
|
| 5 |
enum e { A }; |
| 6 |
struct s { int a; }; |
| 7 |
|
| 8 |
enum e |
| 9 |
fn1 (void) |
| 10 |
{ |
| 11 |
return 0; /* { dg-warning "10:enum conversion from 'int' to 'enum e' in return" } */ |
| 12 |
} |
| 13 |
|
| 14 |
int |
| 15 |
fn2 (struct s s) |
| 16 |
{ |
| 17 |
return s; /* { dg-error "10:incompatible types when returning" } */ |
| 18 |
} |
| 19 |
|
| 20 |
void |
| 21 |
fn3 (void) |
| 22 |
{ |
| 23 |
return 3; /* { dg-warning "10:in function returning void" } */ |
| 24 |
} |
| 25 |
|
| 26 |
int |
| 27 |
fn4 (int *a) |
| 28 |
{ |
| 29 |
return a; /* { dg-warning "10:returning 'int \\*' from a function with return type 'int' makes integer from pointer without a cast" } */ |
| 30 |
} |
| 31 |
|
| 32 |
int * |
| 33 |
fn5 (int a) |
| 34 |
{ |
| 35 |
return a; /* { dg-warning "10:returning 'int' from a function with return type 'int \\*' makes pointer from integer without a cast" } */ |
| 36 |
} |
| 37 |
|
| 38 |
unsigned int * |
| 39 |
fn6 (int *i) |
| 40 |
{ |
| 41 |
return i; /* { dg-warning "10:pointer targets in returning 'int \\*' from a function with return type 'unsigned int \\*' differ" } */ |
| 42 |
} |
| 43 |
|
| 44 |
void * |
| 45 |
fn7 (void (*fp) (void)) |
| 46 |
{ |
| 47 |
return fp; /* { dg-warning "10:ISO C forbids return between function pointer" } */ |
| 48 |
} |