Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/diagnostic/param-type-mismatch-2.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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-error "no matching function" "" { target *-*-* } test_7_usage } | |
138 /* { dg-begin-multiline-output "" } | |
139 return test_7 <const char **> (first, second, third); | |
140 ^ | |
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); | |
145 ^~~~~~ | |
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); | |
151 ^~~~~~ | |
152 { dg-end-multiline-output "" } */ | |
153 } | |
154 | |
155 /* Template class, static function. */ | |
156 | |
157 template <typename T> | |
158 struct s8 { static int member_1 (int one, T two, float three); }; // { dg-line s8_member_1 } | |
159 | |
160 int test_8 (int first, const char *second, float third) | |
161 { | |
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); | |
165 ^~~~~~ | |
166 | | |
167 const char* | |
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); }; | |
172 ~~^~~ | |
173 { dg-end-multiline-output "" } */ | |
174 } | |
175 | |
176 /* Template class, non-static function. */ | |
177 | |
178 template <typename T> | |
179 struct s9 { int member_1 (int one, T two, float three); }; // { dg-line s9_member_1 } | |
180 | |
181 int test_9 (int first, const char *second, float third) | |
182 { | |
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); | |
187 ^~~~~~ | |
188 | | |
189 const char* | |
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); }; | |
194 ~~^~~ | |
195 { dg-end-multiline-output "" } */ | |
196 } | |
197 | |
198 /* Overloaded operator (with one candidate). */ | |
199 | |
200 struct s10 {}; | |
201 | |
202 extern int operator- (const s10&, int); // { dg-line s10_operator } | |
203 | |
204 int test_10 () | |
205 { | |
206 s10 v10_a, v10_b; | |
207 | |
208 return v10_a - v10_b; // { dg-error "no match for" } | |
209 /* { dg-begin-multiline-output "" } | |
210 return v10_a - v10_b; | |
211 ~~~~~~^~~~~~~ | |
212 { dg-end-multiline-output "" } */ | |
213 // { dg-message "candidate" "" { target *-*-* } s10_operator } | |
214 /* { dg-begin-multiline-output "" } | |
215 extern int operator- (const s10&, int); | |
216 ^~~~~~~~ | |
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); | |
221 ^~~ | |
222 { dg-end-multiline-output "" } */ | |
223 } |