2 /* { dg-do compile } */
3 /* { dg-options "-fpermissive -Wc++-compat -Wpedantic" } */
4 /* Test we're printing the types, like the good compiler we are. */
8 extern void foo_E (enum E1
); /* { dg-message "expected 'enum E1' but argument is of type 'int'" } */
9 extern void foo (char *); /* { dg-message "expected 'char \\*' but argument is of type 'int \\*'" } */
10 extern void foo2 (int *); /* { dg-message "expected 'int \\*' but argument is of type 'int'" } */
11 extern void foo3 (int); /* { dg-message "expected 'int' but argument is of type 'int \\*'" } */
12 extern void foo4 (int *); /* { dg-message "expected 'int \\*' but argument is of type 'unsigned int \\*'" } */
17 p
= q
; /* { dg-warning "assignment to 'int \\*' from incompatible pointer type 'char \\*'" } */
18 int *r
= q
; /* { dg-warning "initialization of 'int \\*' from incompatible pointer type 'char \\*'" } */
19 foo (r
); /* { dg-warning "passing argument 1 of 'foo' from incompatible pointer type" } */
20 return p
; /* { dg-warning "returning 'int \\*' from a function with incompatible return type 'char \\*'" } */
26 p
= 1; /* { dg-warning "assignment to 'int \\*' from 'int' makes pointer from integer without a cast" } */
27 int *q
= 1; /* { dg-warning "initialization of 'int \\*' from 'int' makes pointer from integer without a cast" } */
28 foo2 (1); /* { dg-warning "passing argument 1 of 'foo2' makes pointer from integer without a cast" } */
29 return 1; /* { dg-warning "returning 'int' from a function with return type 'int \\*' makes pointer from integer without a cast" } */
35 i
= p
; /* { dg-warning "assignment to 'int' from 'int \\*' makes integer from pointer without a cast" } */
36 int j
= p
; /* { dg-warning "initialization of 'int' from 'int \\*' makes integer from pointer without a cast" } */
37 foo3 (p
); /* { dg-warning "passing argument 1 of 'foo3' makes integer from pointer without a cast" } */
38 return p
; /* { dg-warning "returning 'int \\*' from a function with return type 'int' makes integer from pointer without a cast" } */
42 fn3 (int *p
, unsigned int *u
)
44 p
= u
; /* { dg-warning "pointer targets in assignment from 'unsigned int \\*' to 'int \\*' differ in signedness" } */
45 int *q
= u
; /* { dg-warning "pointer targets in initialization of 'int \\*' from 'unsigned int \\*' differ in signedness" } */
46 foo4 (u
); /* { dg-warning "pointer targets in passing argument 1 of 'foo4' differ in signedness" } */
47 return u
; /* { dg-warning "pointer targets in returning 'unsigned int \\*' from a function with return type 'int \\*' differ in signedness" } */
53 foo_E (B
); /* { dg-warning "enum conversion when passing argument" } */
54 e
= 0; /* { dg-warning "enum conversion from 'int' to 'enum E1' in assignment is invalid" } */
55 enum E1 f
= 0; /* { dg-warning "enum conversion from 'int' to 'enum E1' in initialization is invalid" } */
56 return 0; /* { dg-warning "enum conversion from 'int' to 'enum E1' in return is invalid" } */