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, const char *second, float third)
11 return callee_1 (first, second, third); // { dg-error "27: cannot convert 'const char\\*' to 'const char\\*\\*'" }
12 /* { dg-begin-multiline-output "" }
13 return callee_1 (first, second, third);
17 { dg-end-multiline-output "" } */
18 // { dg-message "initializing argument 2 of 'int callee_1\\(int, const char\\*\\*, float\\)'" "" { target *-*-* } callee_1 }
19 /* { dg-begin-multiline-output "" }
20 extern int callee_1 (int one, const char **two, float three);
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, const char *second, float third)
31 return callee_2 (first, second, third); // { dg-error "27: cannot convert 'const char\\*' to 'const char\\*\\*'" }
32 /* { dg-begin-multiline-output "" }
33 return callee_2 (first, second, third);
37 { dg-end-multiline-output "" } */
38 // { dg-message "initializing argument 2 of 'int callee_2\\(int, const char\\*\\*, float\\)'" "" { target *-*-* } callee_2 }
39 /* { dg-begin-multiline-output "" }
40 extern int callee_2 (int, const char **, float);
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, const char *second, float third)
54 return callee_3 (first, second, third); // { dg-error "27: cannot convert 'const char\\*' to 'const char\\*\\*'" }
55 /* { dg-begin-multiline-output "" }
56 return callee_3 (first, second, third);
60 { dg-end-multiline-output "" } */
61 // { dg-message "initializing argument 2 of 'int callee_3\\(int, const char\\*\\*, float\\)'" "" { target *-*-* } callee_3 }
62 /* { dg-begin-multiline-output "" }
63 static int callee_3 (int one, const char **two, float three)
65 { dg-end-multiline-output "" } */
68 /* static member, with argname. */
70 struct s4 { static int member_1 (int one, const char **two, float three); }; // { dg-line s4_member_1 }
72 int test_4 (int first, const char *second, float third)
74 return s4::member_1 (first, second, third); // { dg-error "31: cannot convert 'const char\\*' to 'const char\\*\\*'" }
75 /* { dg-begin-multiline-output "" }
76 return s4::member_1 (first, second, third);
80 { dg-end-multiline-output "" } */
81 // { dg-message "initializing argument 2 of 'static int s4::member_1\\(int, const char\\*\\*, float\\)'" "" { target *-*-* } s4_member_1 }
82 /* { dg-begin-multiline-output "" }
83 struct s4 { static int member_1 (int one, const char **two, float three); };
85 { dg-end-multiline-output "" } */
88 /* non-static member, with argname. */
90 struct s5 { int member_1 (int one, const char **two, float three); }; // { dg-line s5_member_1 }
92 int test_5 (int first, const char *second, float third)
95 return inst.member_1 (first, second, third); // { dg-error "32: cannot convert 'const char\\*' to 'const char\\*\\*'" }
96 /* { dg-begin-multiline-output "" }
97 return inst.member_1 (first, second, third);
101 { dg-end-multiline-output "" } */
102 // { dg-message "initializing argument 2 of 'int s5::member_1\\(int, const char\\*\\*, float\\)'" "" { target *-*-* } s5_member_1 }
103 /* { dg-begin-multiline-output "" }
104 struct s5 { int member_1 (int one, const char **two, float three); };
106 { dg-end-multiline-output "" } */
109 /* non-static member, with argname, via a ptr. */
111 struct s6 { int member_1 (int one, const char **two, float three); }; // { dg-line s6_member_1 }
113 int test_6 (int first, const char *second, float third, s6 *ptr)
115 return ptr->member_1 (first, second, third); // { dg-error "32: cannot convert 'const char\\*' to 'const char\\*\\*'" }
116 /* { dg-begin-multiline-output "" }
117 return ptr->member_1 (first, second, third);
121 { dg-end-multiline-output "" } */
122 // { dg-message "initializing argument 2 of 'int s6::member_1\\(int, const char\\*\\*, float\\)'" "" { target *-*-* } s6_member_1 }
123 /* { dg-begin-multiline-output "" }
124 struct s6 { int member_1 (int one, const char **two, float three); };
126 { dg-end-multiline-output "" } */
129 /* Template function. */
131 template <typename T>
132 int test_7 (int one, T two, float three); // { dg-line test_7_decl }
134 int test_7 (int first, const char *second, float third)
136 return test_7 <const char **> (first, second, third); // { dg-line test_7_usage }
137 // { dg-error "no matching function" "" { target *-*-* } test_7_usage }
138 /* { dg-begin-multiline-output "" }
139 return test_7 <const char **> (first, second, third);
141 { dg-end-multiline-output "" } */
142 // { dg-message "candidate: 'template<class T> int test_7\\(int, T, float\\)'" "" { target *-*-* } test_7_decl }
143 /* { dg-begin-multiline-output "" }
144 int test_7 (int one, T two, float three);
146 { dg-end-multiline-output "" } */
147 // { dg-message "template argument deduction/substitution failed:" "" { target *-*-* } test_7_decl }
148 // { dg-message "cannot convert 'second' \\(type 'const char\\*'\\) to type 'const char\\*\\*'" "" { target *-*-* } test_7_usage }
149 /* { dg-begin-multiline-output "" }
150 return test_7 <const char **> (first, second, third);
152 { dg-end-multiline-output "" } */
155 /* Template class, static function. */
157 template <typename T>
158 struct s8 { static int member_1 (int one, T two, float three); }; // { dg-line s8_member_1 }
160 int test_8 (int first, const char *second, float third)
162 return s8 <const char **>::member_1 (first, second, third); // { dg-error "47: cannot convert 'const char\\*' to 'const char\\*\\*'" }
163 /* { dg-begin-multiline-output "" }
164 return s8 <const char **>::member_1 (first, second, third);
168 { dg-end-multiline-output "" } */
169 // { dg-message "initializing argument 2 of 'static int s8<T>::member_1\\(int, T, float\\) .with T = const char\\*\\*.'" "" { target *-*-* } s8_member_1 }
170 /* { dg-begin-multiline-output "" }
171 struct s8 { static int member_1 (int one, T two, float three); };
173 { dg-end-multiline-output "" } */
176 /* Template class, non-static function. */
178 template <typename T>
179 struct s9 { int member_1 (int one, T two, float three); }; // { dg-line s9_member_1 }
181 int test_9 (int first, const char *second, float third)
183 s9 <const char **> inst;
184 return inst.member_1 (first, second, third); // { dg-error "32: cannot convert 'const char\\*' to 'const char\\*\\*'" }
185 /* { dg-begin-multiline-output "" }
186 return inst.member_1 (first, second, third);
190 { dg-end-multiline-output "" } */
191 // { dg-message "initializing argument 2 of 'int s9<T>::member_1\\(int, T, float\\) .with T = const char\\*\\*.'" "" { target *-*-* } s9_member_1 }
192 /* { dg-begin-multiline-output "" }
193 struct s9 { int member_1 (int one, T two, float three); };
195 { dg-end-multiline-output "" } */
198 /* Overloaded operator (with one candidate). */
202 extern int operator- (const s10&, int); // { dg-line s10_operator }
208 return v10_a - v10_b; // { dg-error "no match for" }
209 /* { dg-begin-multiline-output "" }
210 return v10_a - v10_b;
212 { dg-end-multiline-output "" } */
213 // { dg-message "candidate" "" { target *-*-* } s10_operator }
214 /* { dg-begin-multiline-output "" }
215 extern int operator- (const s10&, int);
217 { dg-end-multiline-output "" } */
218 // { dg-message "no known conversion for argument 2 from" "" { target *-*-* } s10_operator }
219 /* { dg-begin-multiline-output "" }
220 extern int operator- (const s10&, int);
222 { dg-end-multiline-output "" } */