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                            |
16                            const char*
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);
21                                ~~~~~~~~~~~~~^~~
22      { dg-end-multiline-output "" } */
23 }
24 
25 /* decl, without argname.  */
26 
27 extern int callee_2 (int, const char **, float); // { dg-line callee_2 }
28 
test_2(int first,const char * second,float third)29 int test_2 (int first, const char *second, float third)
30 {
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);
34                            ^~~~~~
35                            |
36                            const char*
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);
41                            ^~~~~~~~~~~~~
42      { dg-end-multiline-output "" } */
43 }
44 
45 /* defn, with argname.  */
46 
callee_3(int one,const char ** two,float three)47 static int callee_3 (int one, const char **two, float three) // { dg-line callee_3 }
48 {
49   return callee_2 (one, two, three);
50 }
51 
test_3(int first,const char * second,float third)52 int test_3 (int first, const char *second, float third)
53 {
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);
57                            ^~~~~~
58                            |
59                            const char*
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)
64                                ~~~~~~~~~~~~~^~~
65      { dg-end-multiline-output "" } */
66 }
67 
68 /* static member, with argname.  */
69 
70 struct s4 { static int member_1 (int one, const char **two, float three); }; // { dg-line s4_member_1 }
71 
test_4(int first,const char * second,float third)72 int test_4 (int first, const char *second, float third)
73 {
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);
77                                ^~~~~~
78                                |
79                                const char*
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); };
84                                            ~~~~~~~~~~~~~^~~
85      { dg-end-multiline-output "" } */
86 }
87 
88 /* non-static member, with argname.  */
89 
90 struct s5 { int member_1 (int one, const char **two, float three); }; // { dg-line s5_member_1 }
91 
test_5(int first,const char * second,float third)92 int test_5 (int first, const char *second, float third)
93 {
94   s5 inst;
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);
98                                 ^~~~~~
99                                 |
100                                 const char*
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); };
105                                     ~~~~~~~~~~~~~^~~
106      { dg-end-multiline-output "" } */
107 }
108 
109 /* non-static member, with argname, via a ptr.  */
110 
111 struct s6 { int member_1 (int one, const char **two, float three); }; // { dg-line s6_member_1 }
112 
test_6(int first,const char * second,float third,s6 * ptr)113 int test_6 (int first, const char *second, float third, s6 *ptr)
114 {
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);
118                                 ^~~~~~
119                                 |
120                                 const char*
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); };
125                                     ~~~~~~~~~~~~~^~~
126      { dg-end-multiline-output "" } */
127 }
128 
129 /* Template function.  */
130 
131 template <typename T>
132 int test_7 (int one, T two, float three); // { dg-line test_7_decl }
133 
test_7(int first,const char * second,float third)134 int test_7 (int first, const char *second, float third)
135 {
136   return test_7 <const char **> (first, second, third); // { dg-line test_7_usage }
137   // { dg-message "cannot convert 'const char\\*' to 'const char\\*\\*'" "" { target *-*-* } test_7_usage }
138   /* { dg-begin-multiline-output "" }
139    return test_7 <const char **> (first, second, third);
140                                          ^~~~~~
141                                          |
142                                          const char*
143      { dg-end-multiline-output "" } */
144   // { dg-message "initializing argument 2 of 'int test_7\\(int, T, float\\) .with T = const char\\*\\*.'" "" { target *-*-* } test_7_decl }
145   /* { dg-begin-multiline-output "" }
146  int test_7 (int one, T two, float three);
147                       ~~^~~
148      { dg-end-multiline-output "" } */
149 }
150 
151 /* Template class, static function.  */
152 
153 template <typename T>
154 struct s8 { static int member_1 (int one, T two, float three); }; // { dg-line s8_member_1 }
155 
test_8(int first,const char * second,float third)156 int test_8 (int first, const char *second, float third)
157 {
158   return s8 <const char **>::member_1 (first, second, third); // { dg-error "47: cannot convert 'const char\\*' to 'const char\\*\\*'" }
159   /* { dg-begin-multiline-output "" }
160    return s8 <const char **>::member_1 (first, second, third);
161                                                ^~~~~~
162                                                |
163                                                const char*
164      { dg-end-multiline-output "" } */
165   // { dg-message "initializing argument 2 of 'static int s8<T>::member_1\\(int, T, float\\) .with T = const char\\*\\*.'" "" { target *-*-* } s8_member_1 }
166   /* { dg-begin-multiline-output "" }
167  struct s8 { static int member_1 (int one, T two, float three); };
168                                            ~~^~~
169      { dg-end-multiline-output "" } */
170 }
171 
172 /* Template class, non-static function.  */
173 
174 template <typename T>
175 struct s9 { int member_1 (int one, T two, float three); }; // { dg-line s9_member_1 }
176 
test_9(int first,const char * second,float third)177 int test_9 (int first, const char *second, float third)
178 {
179   s9 <const char **> inst;
180   return inst.member_1 (first, second, third); // { dg-error "32: cannot convert 'const char\\*' to 'const char\\*\\*'" }
181   /* { dg-begin-multiline-output "" }
182    return inst.member_1 (first, second, third);
183                                 ^~~~~~
184                                 |
185                                 const char*
186      { dg-end-multiline-output "" } */
187   // { dg-message "initializing argument 2 of 'int s9<T>::member_1\\(int, T, float\\) .with T = const char\\*\\*.'" "" { target *-*-* } s9_member_1 }
188   /* { dg-begin-multiline-output "" }
189  struct s9 { int member_1 (int one, T two, float three); };
190                                     ~~^~~
191      { dg-end-multiline-output "" } */
192 }
193 
194 /* Overloaded operator (with one candidate).  */
195 
196 struct s10 {};
197 
198 extern int operator- (const s10&, int); // { dg-line s10_operator }
199 
test_10()200 int test_10 ()
201 {
202   s10 v10_a, v10_b;
203 
204   return v10_a - v10_b; // { dg-error "no match for" }
205   /* { dg-begin-multiline-output "" }
206    return v10_a - v10_b;
207           ~~~~~ ^ ~~~~~
208           |       |
209           s10     s10
210      { dg-end-multiline-output "" } */
211   // { dg-message "candidate" "" { target *-*-* } s10_operator }
212   /* { dg-begin-multiline-output "" }
213  extern int operator- (const s10&, int);
214             ^~~~~~~~
215      { dg-end-multiline-output "" } */
216   // { dg-message "no known conversion for argument 2 from" "" { target *-*-* } s10_operator }
217   /* { dg-begin-multiline-output "" }
218  extern int operator- (const s10&, int);
219                                    ^~~
220      { dg-end-multiline-output "" } */
221 }
222