Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gcc.dg / param-type-mismatch.c
blob9e654a9e9c65abbe260b01ecb264a421d3109560
1 /* { dg-options "-fdiagnostics-show-caret -Wpointer-sign" } */
3 /* A collection of calls where argument 2 is of the wrong type. */
5 /* decl, with argname. */
7 extern int callee_1 (int one, const char *two, float three); /* { dg-line callee_1 } */
9 int test_1 (int first, int second, float third)
11 return callee_1 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_1' makes pointer from integer without a cast" } */
12 /* { dg-begin-multiline-output "" }
13 return callee_1 (first, second, third);
14 ^~~~~~
16 int
17 { dg-end-multiline-output "" } */
18 /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_1 } */
19 /* { dg-begin-multiline-output "" }
20 extern int callee_1 (int one, const char *two, float three);
21 ~~~~~~~~~~~~^~~
22 { dg-end-multiline-output "" } */
25 /* decl, without argname. */
27 extern int callee_2 (int, const char *, float); /* { dg-line callee_2 } */
29 int test_2 (int first, int second, float third)
31 return callee_2 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_2' makes pointer from integer without a cast" } */
32 /* { dg-begin-multiline-output "" }
33 return callee_2 (first, second, third);
34 ^~~~~~
36 int
37 { dg-end-multiline-output "" } */
38 /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_2 } */
39 /* { dg-begin-multiline-output "" }
40 extern int callee_2 (int, const char *, float);
41 ^~~~~~~~~~~~
42 { dg-end-multiline-output "" } */
45 /* defn, with argname. */
47 static int callee_3 (int one, const char *two, float three) /* { dg-line callee_3 } */
49 return callee_2 (one, two, three);
52 int test_3 (int first, int second, float third)
54 return callee_3 (first, second, third); // { dg-warning "passing argument 2 of 'callee_3' makes pointer from integer without a cast" }
55 /* { dg-begin-multiline-output "" }
56 return callee_3 (first, second, third);
57 ^~~~~~
59 int
60 { dg-end-multiline-output "" } */
61 /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_3 } */
62 /* { dg-begin-multiline-output "" }
63 static int callee_3 (int one, const char *two, float three)
64 ~~~~~~~~~~~~^~~
65 { dg-end-multiline-output "" } */
68 /* Trivial decl, with argname. */
70 extern int callee_4 (int one, float two, float three); /* { dg-line callee_4 } */
72 int test_4 (int first, const char *second, float third)
74 return callee_4 (first, second, third); /* { dg-error "incompatible type for argument 2 of 'callee_4'" } */
75 /* { dg-begin-multiline-output "" }
76 return callee_4 (first, second, third);
77 ^~~~~~
79 const char *
80 { dg-end-multiline-output "" } */
81 /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_4 } */
82 /* { dg-begin-multiline-output "" }
83 extern int callee_4 (int one, float two, float three);
84 ~~~~~~^~~
85 { dg-end-multiline-output "" } */
88 /* Trivial decl, without argname. */
90 extern int callee_5 (int, float, float); /* { dg-line callee_5 } */
92 int test_5 (int first, const char *second, float third)
94 return callee_5 (first, second, third); /* { dg-error "incompatible type for argument 2 of 'callee_5'" } */
95 /* { dg-begin-multiline-output "" }
96 return callee_5 (first, second, third);
97 ^~~~~~
99 const char *
100 { dg-end-multiline-output "" } */
101 /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_5 } */
102 /* { dg-begin-multiline-output "" }
103 extern int callee_5 (int, float, float);
104 ^~~~~
105 { dg-end-multiline-output "" } */
108 /* Callback with name. */
110 extern int callee_6 (int one, int (*two)(int, int), float three); /* { dg-line callee_6 } */
112 int test_6 (int first, int second, float third)
114 return callee_6 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_6' makes pointer from integer without a cast" } */
115 /* { dg-begin-multiline-output "" }
116 return callee_6 (first, second, third);
117 ^~~~~~
120 { dg-end-multiline-output "" } */
121 /* { dg-message " expected 'int \\(\\*\\)\\(int, int\\)' but argument is of type 'int'" "" { target *-*-* } callee_6 } */
122 /* { dg-begin-multiline-output "" }
123 extern int callee_6 (int one, int (*two)(int, int), float three);
124 ~~~~~~^~~~~~~~~~~~~~
125 { dg-end-multiline-output "" } */
128 /* Callback without name. */
130 extern int callee_7 (int one, int (*)(int, int), float three); /* { dg-line callee_7 } */
132 int test_7 (int first, int second, float third)
134 return callee_7 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_7' makes pointer from integer without a cast" } */
135 /* { dg-begin-multiline-output "" }
136 return callee_7 (first, second, third);
137 ^~~~~~
140 { dg-end-multiline-output "" } */
141 /* { dg-message " expected 'int \\(\\*\\)\\(int, int\\)' but argument is of type 'int'" "" { target *-*-* } callee_7 } */
142 /* { dg-begin-multiline-output "" }
143 extern int callee_7 (int one, int (*)(int, int), float three);
144 ^~~~~~~~~~~~~~~~~
145 { dg-end-multiline-output "" } */
148 /* -Wincompatible-pointer-types for a parameter. */
150 extern int callee_8 (int one, float *two, float (three)); /* { dg-line callee_8 } */
152 int test_8 (int first, int *second, float third)
154 return callee_8 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_8' from incompatible pointer type" } */
155 /* { dg-begin-multiline-output "" }
156 return callee_8 (first, second, third);
157 ^~~~~~
159 int *
160 { dg-end-multiline-output "" } */
161 /* { dg-message "expected 'float \\*' but argument is of type 'int \\*'" "" { target *-*-* } callee_8 } */
162 /* { dg-begin-multiline-output "" }
163 extern int callee_8 (int one, float *two, float (three));
164 ~~~~~~~^~~
165 { dg-end-multiline-output "" } */
168 /* -Wpointer-sign for a parameter. */
170 extern int callee_9 (int one, int *two, float (three)); /* { dg-line callee_9 } */
172 int test_9 (int first, unsigned int *second, float third)
174 return callee_9 (first, second, third); /* { dg-warning "pointer targets in passing argument 2 of 'callee_9' differ in signedness" } */
175 /* { dg-begin-multiline-output "" }
176 return callee_9 (first, second, third);
177 ^~~~~~
179 unsigned int *
180 { dg-end-multiline-output "" } */
181 /* { dg-message "expected 'int \\*' but argument is of type 'unsigned int \\*'" "" { target *-*-* } callee_9 } */
182 /* { dg-begin-multiline-output "" }
183 extern int callee_9 (int one, int *two, float (three));
184 ~~~~~^~~
185 { dg-end-multiline-output "" } */