| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-Wpedantic" } */ |
| 3 |
/* Test we're printing the types, like the good compiler we are. */ |
| 4 |
|
| 5 |
extern void foo2 (int *); /* { dg-message "expected 'int \\*' but argument is of type 'int'" } */ |
| 6 |
extern void foo3 (int); /* { dg-message "expected 'int' but argument is of type 'int \\*'" } */ |
| 7 |
|
| 8 |
int * |
| 9 |
fn1 (int *p) |
| 10 |
{ |
| 11 |
p = 1; /* { dg-error "assignment to 'int \\*' from 'int' makes pointer from integer without a cast" } */ |
| 12 |
int *q = 1; /* { dg-error "initialization of 'int \\*' from 'int' makes pointer from integer without a cast" } */ |
| 13 |
foo2 (1); /* { dg-error "passing argument 1 of 'foo2' makes pointer from integer without a cast" } */ |
| 14 |
return 1; /* { dg-error "returning 'int' from a function with return type 'int \\*' makes pointer from integer without a cast" } */ |
| 15 |
} |
| 16 |
|
| 17 |
int |
| 18 |
fn2 (int i, int *p) |
| 19 |
{ |
| 20 |
i = p; /* { dg-error "assignment to 'int' from 'int \\*' makes integer from pointer without a cast" } */ |
| 21 |
int j = p; /* { dg-error "initialization of 'int' from 'int \\*' makes integer from pointer without a cast" } */ |
| 22 |
foo3 (p); /* { dg-error "passing argument 1 of 'foo3' makes integer from pointer without a cast" } */ |
| 23 |
return p; /* { dg-error "returning 'int \\*' from a function with return type 'int' makes integer from pointer without a cast" } */ |
| 24 |
} |