1 // { dg-options "-fdiagnostics-show-caret" }
2 
3 /* A collection of calls where argument 2 is of the wrong type.  */
4 
5 /* decl, with argname.  */
6 
7 extern int callee_1 (int one, const char **two, float three); // { dg-line callee_1 }
8 
test_1(int first,const char * second,float third)9 int test_1 (int first, const char *second, float third)
10 {
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);
14                            ^~~~~~
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);
19                                ~~~~~~~~~~~~~^~~
20      { dg-end-multiline-output "" } */
21 }
22 
23 /* decl, without argname.  */
24 
25 extern int callee_2 (int, const char **, float); // { dg-line callee_2 }
26 
test_2(int first,const char * second,float third)27 int test_2 (int first, const char *second, float third)
28 {
29   return callee_2 (first, second, third); // { dg-error "27: cannot convert 'const char\\*' to 'const char\\*\\*'" }
30   /* { dg-begin-multiline-output "" }
31    return callee_2 (first, second, third);
32                            ^~~~~~
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);
37                            ^~~~~~~~~~~~~
38      { dg-end-multiline-output "" } */
39 }
40 
41 /* defn, with argname.  */
42 
callee_3(int one,const char ** two,float three)43 static int callee_3 (int one, const char **two, float three) // { dg-line callee_3 }
44 {
45   return callee_2 (one, two, three);
46 }
47 
test_3(int first,const char * second,float third)48 int test_3 (int first, const char *second, float third)
49 {
50   return callee_3 (first, second, third); // { dg-error "27: cannot convert 'const char\\*' to 'const char\\*\\*'" }
51   /* { dg-begin-multiline-output "" }
52    return callee_3 (first, second, third);
53                            ^~~~~~
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)
58                                ~~~~~~~~~~~~~^~~
59      { dg-end-multiline-output "" } */
60 }
61 
62 /* static member, with argname.  */
63 
64 struct s4 { static int member_1 (int one, const char **two, float three); }; // { dg-line s4_member_1 }
65 
test_4(int first,const char * second,float third)66 int test_4 (int first, const char *second, float third)
67 {
68   return s4::member_1 (first, second, third); // { dg-error "no matching function for call to 's4::member_1\\(int&, const char\\*&, float&\\)'" }
69   /* { dg-begin-multiline-output "" }
70    return s4::member_1 (first, second, third);
71                                             ^
72      { dg-end-multiline-output "" } */
73   // { dg-message "candidate: 'static int s4::member_1\\(int, const char\\*\\*, float\\)'" "" { target *-*-* } s4_member_1 }
74   /* { dg-begin-multiline-output "" }
75  struct s4 { static int member_1 (int one, const char **two, float three); };
76                         ^~~~~~~~
77      { dg-end-multiline-output "" } */
78   // { dg-message "no known conversion for argument 2 from 'const char\\*' to 'const char\\*\\*'" "" { target *-*-* } s4_member_1 }
79   // TODO: underline the pertinent param
80 }
81 
82 /* non-static member, with argname.  */
83 
84 struct s5 { int member_1 (int one, const char **two, float three); }; // { dg-line s5_member_1 }
85 
test_5(int first,const char * second,float third)86 int test_5 (int first, const char *second, float third)
87 {
88   s5 inst;
89   return inst.member_1 (first, second, third); // { dg-error "no matching function for call to 's5::member_1\\(int&, const char\\*&, float&\\)'" }
90   /* { dg-begin-multiline-output "" }
91    return inst.member_1 (first, second, third);
92                                              ^
93      { dg-end-multiline-output "" } */
94   // { dg-message "candidate: 'int s5::member_1\\(int, const char\\*\\*, float\\)'" "" { target *-*-* } s5_member_1 }
95   /* { dg-begin-multiline-output "" }
96  struct s5 { int member_1 (int one, const char **two, float three); };
97                  ^~~~~~~~
98      { dg-end-multiline-output "" } */
99   // { dg-message "no known conversion for argument 2 from 'const char\\*' to 'const char\\*\\*'" "" { target *-*-* } s5_member_1 }
100   // TODO: underline the pertinent param
101 }
102 
103 /* non-static member, with argname, via a ptr.  */
104 
105 struct s6 { int member_1 (int one, const char **two, float three); }; // { dg-line s6_member_1 }
106 
test_6(int first,const char * second,float third,s6 * ptr)107 int test_6 (int first, const char *second, float third, s6 *ptr)
108 {
109   return ptr->member_1 (first, second, third); // { dg-error "no matching function for call to 's6::member_1\\(int&, const char\\*&, float&\\)'" }
110   /* { dg-begin-multiline-output "" }
111    return ptr->member_1 (first, second, third);
112                                              ^
113      { dg-end-multiline-output "" } */
114   // { dg-message "candidate: 'int s6::member_1\\(int, const char\\*\\*, float\\)'" "" { target *-*-* } s6_member_1 }
115   /* { dg-begin-multiline-output "" }
116  struct s6 { int member_1 (int one, const char **two, float three); };
117                  ^~~~~~~~
118      { dg-end-multiline-output "" } */
119   // { dg-message "no known conversion for argument 2 from 'const char\\*' to 'const char\\*\\*'" "" { target *-*-* } s6_member_1 }
120   // TODO: underline the pertinent param
121 }
122 
123 /* Template function.  */
124 
125 template <typename T>
126 int test_7 (int one, T two, float three); // { dg-line test_7_decl }
127 
test_7(int first,const char * second,float third)128 int test_7 (int first, const char *second, float third)
129 {
130   return test_7 <const char **> (first, second, third); // { dg-line test_7_usage }
131   // { dg-error "no matching function" "" { target *-*-* } test_7_usage }
132   /* { dg-begin-multiline-output "" }
133    return test_7 <const char **> (first, second, third);
134                                                       ^
135      { dg-end-multiline-output "" } */
136   // { dg-message "candidate: 'template<class T> int test_7\\(int, T, float\\)'" "" { target *-*-* } test_7_decl }
137   /* { dg-begin-multiline-output "" }
138  int test_7 (int one, T two, float three);
139      ^~~~~~
140      { dg-end-multiline-output "" } */
141   // { dg-message "template argument deduction/substitution failed:" "" { target *-*-* } test_7_decl }
142   // { dg-message "cannot convert 'second' \\(type 'const char\\*'\\) to type 'const char\\*\\*'" "" { target *-*-* } test_7_usage }
143   /* { dg-begin-multiline-output "" }
144    return test_7 <const char **> (first, second, third);
145                                          ^~~~~~
146      { dg-end-multiline-output "" } */
147 }
148 
149 /* Template class, static function.  */
150 
151 template <typename T>
152 struct s8 { static int member_1 (int one, T two, float three); }; // { dg-line s8_member_1 }
153 
test_8(int first,const char * second,float third)154 int test_8 (int first, const char *second, float third)
155 {
156   return s8 <const char **>::member_1 (first, second, third); // { dg-error "no matching function for call to 's8<const char\\*\\*>::member_1\\(int&, const char\\*&, float&\\)'" }
157   /* { dg-begin-multiline-output "" }
158    return s8 <const char **>::member_1 (first, second, third);
159                                                             ^
160      { dg-end-multiline-output "" } */
161   // { dg-message "candidate: 'static int s8<T>::member_1\\(int, T, float\\)" "" { target *-*-* } s8_member_1 }
162   /* { dg-begin-multiline-output "" }
163  struct s8 { static int member_1 (int one, T two, float three); };
164                         ^~~~~~~~
165      { dg-end-multiline-output "" } */
166   // { dg-message "no known conversion for argument 2 from 'const char\\*' to 'const char\\*\\*'" "" { target *-*-* } s8_member_1 }
167   // TODO: underline the pertinent param
168 }
169 
170 /* Template class, non-static function.  */
171 
172 template <typename T>
173 struct s9 { int member_1 (int one, T two, float three); }; // { dg-line s9_member_1 }
174 
test_9(int first,const char * second,float third)175 int test_9 (int first, const char *second, float third)
176 {
177   s9 <const char **> inst;
178   return inst.member_1 (first, second, third); // { dg-error "no matching function for call to 's9<const char\\*\\*>::member_1\\(int&, const char\\*&, float&\\)'" }
179   /* { dg-begin-multiline-output "" }
180    return inst.member_1 (first, second, third);
181                                              ^
182      { dg-end-multiline-output "" } */
183   // { dg-message "candidate: 'int s9<T>::member_1\\(int, T, float\\)" "" { target *-*-* } s9_member_1 }
184   /* { dg-begin-multiline-output "" }
185  struct s9 { int member_1 (int one, T two, float three); };
186                  ^~~~~~~~
187      { dg-end-multiline-output "" } */
188   // { dg-message "no known conversion for argument 2 from 'const char\\*' to 'const char\\*\\*'" "" { target *-*-* } s9_member_1 }
189   // TODO: underline the pertinent param
190 }
191