1 // { dg-options "-fdiagnostics-show-caret" }
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-error "invalid conversion from 'int' to 'const char\\*'" }
12 /* { dg-begin-multiline-output "" }
13 return callee_1 (first, second, third);
15 { dg-end-multiline-output "" } */
16 // { dg-message "initializing argument 2 of 'int callee_1\\(int, const char\\*, float\\)'" "" { target *-*-* } callee_1 }
17 /* { dg-begin-multiline-output "" }
18 extern int callee_1 (int one, const char *two, float three);
20 { dg-end-multiline-output "" } */
23 /* decl, without argname. */
25 extern int callee_2 (int, const char *, float); // { dg-line callee_2 }
27 int test_2 (int first, int second, float third)
29 return callee_2 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" }
30 /* { dg-begin-multiline-output "" }
31 return callee_2 (first, second, third);
33 { dg-end-multiline-output "" } */
34 // { dg-message "initializing argument 2 of 'int callee_2\\(int, const char\\*, float\\)'" "" { target *-*-* } callee_2 }
35 /* { dg-begin-multiline-output "" }
36 extern int callee_2 (int, const char *, float);
38 { dg-end-multiline-output "" } */
41 /* defn, with argname. */
43 static int callee_3 (int one, const char *two, float three) // { dg-line callee_3 }
45 return callee_2 (one, two, three);
48 int test_3 (int first, int second, float third)
50 return callee_3 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" }
51 /* { dg-begin-multiline-output "" }
52 return callee_3 (first, second, third);
54 { dg-end-multiline-output "" } */
55 // { dg-message "initializing argument 2 of 'int callee_3\\(int, const char\\*, float\\)'" "" { target *-*-* } callee_3 }
56 /* { dg-begin-multiline-output "" }
57 static int callee_3 (int one, const char *two, float three)
59 { dg-end-multiline-output "" } */
62 /* static member, with argname. */
64 struct s4 { static int member_1 (int one, const char *two, float three); };
66 int test_4 (int first, int second, float third)
68 return s4::member_1 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" }
69 /* { dg-begin-multiline-output "" }
70 return s4::member_1 (first, second, third);
72 { dg-end-multiline-output "" } */
73 /* { dg-begin-multiline-output "" }
74 struct s4 { static int member_1 (int one, const char *two, float three); };
76 { dg-end-multiline-output "" } */
79 /* non-static member, with argname. */
81 struct s5 { int member_1 (int one, const char *two, float three); };
83 int test_5 (int first, int second, float third)
86 return inst.member_1 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" }
87 /* { dg-begin-multiline-output "" }
88 return inst.member_1 (first, second, third);
90 { dg-end-multiline-output "" } */
91 /* { dg-begin-multiline-output "" }
92 struct s5 { int member_1 (int one, const char *two, float three); };
94 { dg-end-multiline-output "" } */
97 /* non-static member, with argname, via a ptr. */
99 struct s6 { int member_1 (int one, const char *two, float three); };
101 int test_6 (int first, int second, float third, s6 *ptr)
103 return ptr->member_1 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" }
104 /* { dg-begin-multiline-output "" }
105 return ptr->member_1 (first, second, third);
107 { dg-end-multiline-output "" } */
108 /* { dg-begin-multiline-output "" }
109 struct s6 { int member_1 (int one, const char *two, float three); };
111 { dg-end-multiline-output "" } */
114 /* Template function. */
116 template <typename T>
117 int test_7 (int one, T two, float three);
119 int test_7 (int first, int second, float third)
121 return test_7 <const char *> (first, second, third); // { dg-error "no matching function" }
122 /* { dg-begin-multiline-output "" }
123 return test_7 <const char *> (first, second, third);
125 { dg-end-multiline-output "" } */
126 /* { dg-begin-multiline-output "" }
127 return test_7 <const char *> (first, second, third);
129 { dg-end-multiline-output "" } */
130 /* { dg-begin-multiline-output "" }
131 int test_7 (int one, T two, float three);
133 { dg-end-multiline-output "" } */
136 /* Template class, static function. */
138 template <typename T>
139 struct s8 { static int member_1 (int one, T two, float three); };
141 int test_8 (int first, int second, float third)
143 return s8 <const char *>::member_1 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" }
144 /* { dg-begin-multiline-output "" }
145 return s8 <const char *>::member_1 (first, second, third);
147 { dg-end-multiline-output "" } */
148 /* { dg-begin-multiline-output "" }
149 struct s8 { static int member_1 (int one, T two, float three); };
151 { dg-end-multiline-output "" } */
154 /* Template class, non-static function. */
156 template <typename T>
157 struct s9 { int member_1 (int one, T two, float three); };
159 int test_9 (int first, int second, float third)
161 s9 <const char *> inst;
162 return inst.member_1 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" }
163 /* { dg-begin-multiline-output "" }
164 return inst.member_1 (first, second, third);
166 { dg-end-multiline-output "" } */
167 /* { dg-begin-multiline-output "" }
168 struct s9 { int member_1 (int one, T two, float three); };
170 { dg-end-multiline-output "" } */
173 /* Callback with name. */
175 extern int callee_10 (int one, int (*two)(int, int), float three); // { dg-line callee_10 }
177 int test_10 (int first, int second, float third)
179 return callee_10 (first, second, third); // { dg-error "invalid conversion from 'int' to 'int \\(\\*\\)\\(int, int\\)'" }
180 /* { dg-begin-multiline-output "" }
181 return callee_10 (first, second, third);
183 { dg-end-multiline-output "" } */
184 // { dg-message "initializing argument 2 of 'int callee_10\\(int, int \\(\\*\\)\\(int, int\\), float\\)'" "" { target *-*-* } callee_10 }
185 /* { dg-begin-multiline-output "" }
186 extern int callee_10 (int one, int (*two)(int, int), float three);
188 { dg-end-multiline-output "" } */
191 /* Callback without name. */
193 extern int callee_11 (int one, int (*)(int, int), float three); // { dg-line callee_11 }
195 int test_11 (int first, int second, float third)
197 return callee_11 (first, second, third); // { dg-error "invalid conversion from 'int' to 'int \\(\\*\\)\\(int, int\\)'" }
198 /* { dg-begin-multiline-output "" }
199 return callee_11 (first, second, third);
201 { dg-end-multiline-output "" } */
202 // { dg-message "initializing argument 2 of 'int callee_11\\(int, int \\(\\*\\)\\(int, int\\), float\\)'" "" { target *-*-* } callee_11 }
203 /* { dg-begin-multiline-output "" }
204 extern int callee_11 (int one, int (*)(int, int), float three);
206 { dg-end-multiline-output "" } */
209 // TODO: template callsite