Commit | Line | Data |
---|---|---|
8955eb2d PA |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
e2882c85 | 3 | Copyright 2017-2018 Free Software Foundation, Inc. |
8955eb2d PA |
4 | |
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 3 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
17 | ||
18 | /* Code for the all-param-prefixes test. */ | |
19 | ||
20 | void | |
21 | param_prefixes_test_long (long) | |
22 | {} | |
23 | ||
24 | void | |
25 | param_prefixes_test_intp_intr (int *, int&) | |
26 | {} | |
27 | ||
28 | /* Code for the overload test. */ | |
29 | ||
30 | void | |
31 | overload_ambiguous_test (long) | |
32 | {} | |
33 | ||
34 | void | |
35 | overload_ambiguous_test (int, int) | |
36 | {} | |
37 | ||
38 | void | |
39 | overload_ambiguous_test (int, long) | |
40 | {} | |
41 | ||
42 | /* Code for the overload-2 test. */ | |
43 | ||
44 | /* Generate functions/methods all with the same name, in different | |
45 | scopes, but all with different parameters. */ | |
46 | ||
47 | struct overload2_arg1 {}; | |
48 | struct overload2_arg2 {}; | |
49 | struct overload2_arg3 {}; | |
50 | struct overload2_arg4 {}; | |
51 | struct overload2_arg5 {}; | |
52 | struct overload2_arg6 {}; | |
53 | struct overload2_arg7 {}; | |
54 | struct overload2_arg8 {}; | |
55 | struct overload2_arg9 {}; | |
56 | struct overload2_arga {}; | |
57 | ||
58 | #define GEN_OVERLOAD2_FUNCTIONS(ARG1, ARG2) \ | |
59 | void \ | |
60 | overload2_function (ARG1) \ | |
61 | {} \ | |
62 | \ | |
63 | struct struct_overload2_test \ | |
64 | { \ | |
65 | void overload2_function (ARG2); \ | |
66 | }; \ | |
67 | \ | |
68 | void \ | |
69 | struct_overload2_test::overload2_function (ARG2) \ | |
70 | {} | |
71 | ||
72 | /* In the global namespace. */ | |
73 | GEN_OVERLOAD2_FUNCTIONS( overload2_arg1, overload2_arg2) | |
74 | ||
75 | namespace | |
76 | { | |
77 | /* In an anonymous namespace. */ | |
78 | GEN_OVERLOAD2_FUNCTIONS (overload2_arg3, overload2_arg4) | |
79 | } | |
80 | ||
81 | namespace ns_overload2_test | |
82 | { | |
83 | /* In a namespace. */ | |
84 | GEN_OVERLOAD2_FUNCTIONS (overload2_arg5, overload2_arg6) | |
85 | ||
86 | namespace | |
87 | { | |
88 | /* In a nested anonymous namespace. */ | |
89 | GEN_OVERLOAD2_FUNCTIONS (overload2_arg7, overload2_arg8) | |
90 | ||
91 | namespace ns_overload2_test | |
92 | { | |
93 | /* In a nested namespace. */ | |
94 | GEN_OVERLOAD2_FUNCTIONS (overload2_arg9, overload2_arga) | |
95 | } | |
96 | } | |
97 | } | |
98 | ||
99 | /* Code for the overload-3 test. */ | |
100 | ||
101 | #define GEN_OVERLOAD3_FUNCTIONS(ARG1, ARG2) \ | |
102 | void \ | |
103 | overload3_function (ARG1) \ | |
104 | {} \ | |
105 | void \ | |
106 | overload3_function (ARG2) \ | |
107 | {} \ | |
108 | \ | |
109 | struct struct_overload3_test \ | |
110 | { \ | |
111 | void overload3_function (ARG1); \ | |
112 | void overload3_function (ARG2); \ | |
113 | }; \ | |
114 | \ | |
115 | void \ | |
116 | struct_overload3_test::overload3_function (ARG1) \ | |
117 | {} \ | |
118 | void \ | |
119 | struct_overload3_test::overload3_function (ARG2) \ | |
120 | {} | |
121 | ||
122 | /* In the global namespace. */ | |
123 | GEN_OVERLOAD3_FUNCTIONS (int, long) | |
124 | ||
125 | namespace | |
126 | { | |
127 | /* In an anonymous namespace. */ | |
128 | GEN_OVERLOAD3_FUNCTIONS (int, long) | |
129 | } | |
130 | ||
131 | namespace ns_overload3_test | |
132 | { | |
133 | /* In a namespace. */ | |
134 | GEN_OVERLOAD3_FUNCTIONS (int, long) | |
135 | ||
136 | namespace | |
137 | { | |
138 | /* In a nested anonymous namespace. */ | |
139 | GEN_OVERLOAD3_FUNCTIONS (int, long) | |
140 | ||
141 | namespace ns_overload3_test | |
142 | { | |
143 | /* In a nested namespace. */ | |
144 | GEN_OVERLOAD3_FUNCTIONS (int, long) | |
145 | } | |
146 | } | |
147 | } | |
148 | ||
149 | /* Code for the template-overload tests. */ | |
150 | ||
151 | template <typename T> | |
152 | struct template_struct | |
153 | { | |
154 | T template_overload_fn (T); | |
155 | }; | |
156 | ||
157 | template <typename T> | |
158 | T template_struct<T>::template_overload_fn (T t) | |
159 | { | |
160 | return t; | |
161 | } | |
162 | ||
163 | template_struct<int> template_struct_int; | |
164 | template_struct<long> template_struct_long; | |
165 | ||
166 | /* Code for the template2-ret-type tests. */ | |
167 | ||
168 | template <typename T> | |
169 | struct template2_ret_type {}; | |
170 | ||
171 | template <typename T> | |
172 | struct template2_struct | |
173 | { | |
174 | template <typename T2, typename T3> | |
175 | T template2_fn (T = T (), T2 t2 = T2 (), T3 t3 = T3 ()); | |
176 | }; | |
177 | ||
178 | template <typename T> | |
179 | template <typename T2, typename T3> | |
180 | T template2_struct<T>::template2_fn (T t, T2 t2, T3 t3) | |
181 | { | |
182 | return T (); | |
183 | } | |
184 | ||
185 | template2_struct<template2_ret_type<int> > template2_struct_inst; | |
186 | ||
187 | /* Code for the const-overload tests. */ | |
188 | ||
189 | struct struct_with_const_overload | |
190 | { | |
191 | void const_overload_fn (); | |
192 | void const_overload_fn () const; | |
193 | }; | |
194 | ||
195 | void | |
196 | struct_with_const_overload::const_overload_fn () | |
197 | {} | |
198 | ||
199 | void | |
200 | struct_with_const_overload::const_overload_fn () const | |
201 | {} | |
202 | ||
203 | void | |
204 | not_overloaded_fn () | |
205 | {} | |
206 | ||
207 | /* Code for the incomplete-scope-colon tests. */ | |
208 | ||
209 | struct struct_incomplete_scope_colon_test | |
210 | { | |
211 | void incomplete_scope_colon_test (); | |
212 | }; | |
213 | ||
214 | void | |
215 | struct_incomplete_scope_colon_test::incomplete_scope_colon_test () | |
216 | {} | |
217 | ||
218 | namespace ns_incomplete_scope_colon_test | |
219 | { | |
220 | void incomplete_scope_colon_test () {} | |
221 | } | |
222 | ||
223 | namespace ns2_incomplete_scope_colon_test | |
224 | { | |
225 | struct struct_in_ns2_incomplete_scope_colon_test | |
226 | { | |
227 | void incomplete_scope_colon_test (); | |
228 | }; | |
229 | ||
230 | void | |
231 | struct_in_ns2_incomplete_scope_colon_test::incomplete_scope_colon_test () | |
232 | {} | |
233 | } | |
234 | ||
235 | /* Code for the anon-ns tests. */ | |
236 | ||
237 | namespace | |
238 | { | |
239 | void anon_ns_function () | |
240 | {} | |
241 | ||
242 | struct anon_ns_struct | |
243 | { | |
244 | void anon_ns_function (); | |
245 | }; | |
246 | ||
247 | void | |
248 | anon_ns_struct::anon_ns_function () | |
249 | {} | |
250 | } | |
251 | ||
252 | namespace the_anon_ns_wrapper_ns | |
253 | { | |
254 | ||
255 | namespace | |
256 | { | |
257 | void anon_ns_function () | |
258 | {} | |
259 | ||
260 | struct anon_ns_struct | |
261 | { | |
262 | void anon_ns_function (); | |
263 | }; | |
264 | ||
265 | void | |
266 | anon_ns_struct::anon_ns_function () | |
267 | {} | |
268 | } | |
269 | ||
270 | } /* the_anon_ns_wrapper_ns */ | |
271 | ||
272 | /* Code for the global-ns-scope-op tests. */ | |
273 | ||
274 | void global_ns_scope_op_function () | |
275 | { | |
276 | } | |
277 | ||
278 | /* Add a function with the same name to a namespace. We want to test | |
279 | that "b ::global_ns_function" does NOT select it. */ | |
280 | namespace the_global_ns_scope_op_ns | |
281 | { | |
282 | void global_ns_scope_op_function () | |
283 | { | |
284 | } | |
285 | } | |
286 | ||
287 | /* Code for the ambiguous-prefix tests. */ | |
288 | ||
289 | /* Create a few functions/methods with the same "ambiguous_prefix_" | |
290 | prefix. They in different scopes, but "b ambiguous_prefix_<tab>" | |
291 | should list them all, and figure out the LCD is | |
292 | ambiguous_prefix_. */ | |
293 | ||
294 | void ambiguous_prefix_global_func () | |
295 | { | |
296 | } | |
297 | ||
298 | namespace the_ambiguous_prefix_ns | |
299 | { | |
300 | void ambiguous_prefix_ns_func () | |
301 | { | |
302 | } | |
303 | } | |
304 | ||
305 | struct the_ambiguous_prefix_struct | |
306 | { | |
307 | void ambiguous_prefix_method (); | |
308 | }; | |
309 | ||
310 | void | |
311 | the_ambiguous_prefix_struct::ambiguous_prefix_method () | |
312 | { | |
313 | } | |
314 | ||
315 | /* Code for the function-labels test. */ | |
316 | ||
317 | int | |
318 | function_with_labels (int i) | |
319 | { | |
320 | if (i > 0) | |
321 | { | |
322 | label1: | |
323 | return i + 20; | |
324 | } | |
325 | else | |
326 | { | |
327 | label2: | |
328 | return i + 10; | |
329 | } | |
330 | } | |
331 | ||
332 | /* Code for the no-data-symbols and if-expression tests. */ | |
333 | ||
334 | int code_data = 0; | |
335 | ||
336 | int another_data = 0; | |
337 | ||
338 | /* A function that has a same "code" prefix as the global above. We | |
339 | want to ensure that completing on "b code" doesn't offer the data | |
340 | symbol. */ | |
341 | void | |
342 | code_function () | |
343 | { | |
344 | } | |
345 | ||
346 | /* Code for the operator< tests. */ | |
347 | ||
348 | enum foo_enum | |
349 | { | |
350 | foo_value | |
351 | }; | |
352 | ||
353 | bool operator<(foo_enum lhs, foo_enum rhs) | |
354 | { | |
355 | label1: | |
356 | return false; | |
357 | } | |
358 | ||
359 | /* Code for the in-source-file-unconstrained / | |
360 | in-source-file-ambiguous tests. */ | |
361 | ||
362 | int | |
363 | file_constrained_test_cpls_function (int i) | |
364 | { | |
365 | if (i > 0) | |
366 | { | |
367 | label1: | |
368 | return i + 20; | |
369 | } | |
370 | else | |
371 | { | |
372 | label2: | |
373 | return i + 10; | |
374 | } | |
375 | } | |
376 | ||
377 | ||
378 | int | |
379 | main () | |
380 | { | |
381 | template2_struct_inst.template2_fn<int, int> (); | |
382 | template_struct_int.template_overload_fn(0); | |
383 | template_struct_long.template_overload_fn(0); | |
384 | ||
385 | return 0; | |
386 | } |