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,int second,float third)9 int test_1 (int first, int second, float third)
10 {
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);
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,int second,float third)27 int test_2 (int first, int second, float third)
28 {
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);
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,int second,float third)48 int test_3 (int first, int second, float third)
49 {
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);
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); };
65 
test_4(int first,int second,float third)66 int test_4 (int first, int second, float third)
67 {
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);
71                                ^~~~~~
72      { dg-end-multiline-output "" } */
73   /* { dg-begin-multiline-output "" }
74  struct s4 { static int member_1 (int one, const char *two, float three); };
75                                            ~~~~~~~~~~~~^~~
76      { dg-end-multiline-output "" } */
77 }
78 
79 /* non-static member, with argname.  */
80 
81 struct s5 { int member_1 (int one, const char *two, float three); };
82 
test_5(int first,int second,float third)83 int test_5 (int first, int second, float third)
84 {
85   s5 inst;
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);
89                                 ^~~~~~
90      { dg-end-multiline-output "" } */
91   /* { dg-begin-multiline-output "" }
92  struct s5 { int member_1 (int one, const char *two, float three); };
93                                     ~~~~~~~~~~~~^~~
94      { dg-end-multiline-output "" } */
95 }
96 
97 /* non-static member, with argname, via a ptr.  */
98 
99 struct s6 { int member_1 (int one, const char *two, float three); };
100 
test_6(int first,int second,float third,s6 * ptr)101 int test_6 (int first, int second, float third, s6 *ptr)
102 {
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);
106                                 ^~~~~~
107      { dg-end-multiline-output "" } */
108   /* { dg-begin-multiline-output "" }
109  struct s6 { int member_1 (int one, const char *two, float three); };
110                                     ~~~~~~~~~~~~^~~
111      { dg-end-multiline-output "" } */
112 }
113 
114 /* Template function.  */
115 
116 template <typename T>
117 int test_7 (int one, T two, float three);
118 
test_7(int first,int second,float third)119 int test_7 (int first, int second, float third)
120 {
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);
124                                                      ^
125      { dg-end-multiline-output "" } */
126   /* { dg-begin-multiline-output "" }
127    return test_7 <const char *> (first, second, third);
128                                         ^~~~~~
129      { dg-end-multiline-output "" } */
130   /* { dg-begin-multiline-output "" }
131  int test_7 (int one, T two, float three);
132      ^~~~~~
133      { dg-end-multiline-output "" } */
134 }
135 
136 /* Template class, static function.  */
137 
138 template <typename T>
139 struct s8 { static int member_1 (int one, T two, float three); };
140 
test_8(int first,int second,float third)141 int test_8 (int first, int second, float third)
142 {
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);
146                                               ^~~~~~
147      { dg-end-multiline-output "" } */
148   /* { dg-begin-multiline-output "" }
149  struct s8 { static int member_1 (int one, T two, float three); };
150                                            ~~^~~
151      { dg-end-multiline-output "" } */
152 }
153 
154 /* Template class, non-static function.  */
155 
156 template <typename T>
157 struct s9 { int member_1 (int one, T two, float three); };
158 
test_9(int first,int second,float third)159 int test_9 (int first, int second, float third)
160 {
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);
165                                 ^~~~~~
166      { dg-end-multiline-output "" } */
167   /* { dg-begin-multiline-output "" }
168  struct s9 { int member_1 (int one, T two, float three); };
169                                     ~~^~~
170      { dg-end-multiline-output "" } */
171 }
172 
173 /* Callback with name.  */
174 
175 extern int callee_10 (int one, int (*two)(int, int), float three); // { dg-line callee_10 }
176 
test_10(int first,int second,float third)177 int test_10 (int first, int second, float third)
178 {
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);
182                             ^~~~~~
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);
187                                 ~~~~~~^~~~~~~~~~~~~~
188      { dg-end-multiline-output "" } */
189 }
190 
191 /* Callback without name.  */
192 
193 extern int callee_11 (int one, int (*)(int, int), float three); // { dg-line callee_11 }
194 
test_11(int first,int second,float third)195 int test_11 (int first, int second, float third)
196 {
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);
200                             ^~~~~~
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);
205                                 ^~~~~~~~~~~~~~~~~
206      { dg-end-multiline-output "" } */
207 }
208 
209 // TODO: template callsite
210