1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2017-2024 Free Software Foundation, Inc.
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.
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.
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/>. */
18 /* Code for the all-param-prefixes test. */
21 param_prefixes_test_long (long)
25 param_prefixes_test_intp_intr (int *, int&)
28 /* Code for the overload test. */
31 overload_ambiguous_test (long)
35 overload_ambiguous_test (int, int)
39 overload_ambiguous_test (int, long)
42 /* Code for the overload-2 test. */
44 /* Generate functions/methods all with the same name, in different
45 scopes, but all with different parameters. */
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
{};
58 #define GEN_OVERLOAD2_FUNCTIONS(ARG1, ARG2) \
59 void __attribute__ ((used)) \
60 overload2_function (ARG1) \
63 struct struct_overload2_test \
65 void __attribute__ ((used)) \
66 overload2_function (ARG2); \
69 void __attribute__ ((used)) \
70 struct_overload2_test::overload2_function (ARG2) \
73 /* In the global namespace. */
74 GEN_OVERLOAD2_FUNCTIONS( overload2_arg1
, overload2_arg2
)
78 /* In an anonymous namespace. */
79 GEN_OVERLOAD2_FUNCTIONS (overload2_arg3
, overload2_arg4
)
82 namespace ns_overload2_test
85 GEN_OVERLOAD2_FUNCTIONS (overload2_arg5
, overload2_arg6
)
89 /* In a nested anonymous namespace. */
90 GEN_OVERLOAD2_FUNCTIONS (overload2_arg7
, overload2_arg8
)
92 namespace ns_overload2_test
94 /* In a nested namespace. */
95 GEN_OVERLOAD2_FUNCTIONS (overload2_arg9
, overload2_arga
)
100 /* Code for the overload-3 test. */
102 #define GEN_OVERLOAD3_FUNCTIONS(ARG1, ARG2) \
103 void __attribute__ ((used)) \
104 overload3_function (ARG1) \
106 void __attribute__ ((used)) \
107 overload3_function (ARG2) \
110 struct struct_overload3_test \
112 void __attribute__ ((used)) \
113 overload3_function (ARG1); \
114 void __attribute__ ((used)) \
115 overload3_function (ARG2); \
118 void __attribute__ ((used)) \
119 struct_overload3_test::overload3_function (ARG1) \
121 void __attribute__ ((used)) \
122 struct_overload3_test::overload3_function (ARG2) \
125 /* In the global namespace. */
126 GEN_OVERLOAD3_FUNCTIONS (int, long)
130 /* In an anonymous namespace. */
131 GEN_OVERLOAD3_FUNCTIONS (int, long)
134 namespace ns_overload3_test
136 /* In a namespace. */
137 GEN_OVERLOAD3_FUNCTIONS (int, long)
141 /* In a nested anonymous namespace. */
142 GEN_OVERLOAD3_FUNCTIONS (int, long)
144 namespace ns_overload3_test
146 /* In a nested namespace. */
147 GEN_OVERLOAD3_FUNCTIONS (int, long)
152 /* Code for the template-function_foo (template parameter completion) tests. */
154 template <typename T
>
155 struct template_struct
157 T
template_overload_fn (T
);
160 template <typename T
>
161 T template_struct
<T
>::template_overload_fn (T t
)
166 template_struct
<int> template_struct_int
;
167 template_struct
<long> template_struct_long
;
169 /* Code for the template-parameter-overload test. */
171 template <typename T
>
174 template <typename T1
, typename T2
>
175 void foo (T1 a
, T2 b
) {}
177 template <typename T
>
183 template <typename T
>
189 template <typename T
>
195 template <typename T
>
201 template <typename T1
, typename T2
>
207 template <typename T1
, typename T2
>
218 template <typename T1
, typename T2
>
221 template <typename T1
, typename T2
>
226 template_function_foo ()
244 A
<a
<b
<int>>, c
<d
<int>>> Aabcd
;
248 A
<a
<b
<int>>, a
<a
<int>>> Aabaa
;
252 A
<a
<b
<int>>, a
<b
<int>>> Aabab
;
256 B
<a
<b
<int>>, c
<d
<int>>> Babcd
;
271 n::NA
<n::na
, n::nb
> NAnanb
;
272 n::NB
<n::na
, n::nb
> Nbnanb
;
273 foo (NAnanb
, Nbnanb
);
276 /* Code for the template2-ret-type tests. */
278 template <typename T
>
279 struct template2_ret_type
{};
281 template <typename T
>
282 struct template2_struct
284 template <typename T2
, typename T3
>
285 T
template2_fn (T
= T (), T2 t2
= T2 (), T3 t3
= T3 ());
288 template <typename T
>
289 template <typename T2
, typename T3
>
290 T template2_struct
<T
>::template2_fn (T t
, T2 t2
, T3 t3
)
295 template2_struct
<template2_ret_type
<int> > template2_struct_inst
;
297 /* Code for the const-overload tests. */
299 struct struct_with_const_overload
301 void const_overload_fn ();
302 void const_overload_fn () const;
306 struct_with_const_overload::const_overload_fn ()
310 struct_with_const_overload::const_overload_fn () const
317 /* Code for the incomplete-scope-colon tests. */
319 struct struct_incomplete_scope_colon_test
321 void incomplete_scope_colon_test ();
325 struct_incomplete_scope_colon_test::incomplete_scope_colon_test ()
328 namespace ns_incomplete_scope_colon_test
330 void incomplete_scope_colon_test () {}
333 namespace ns2_incomplete_scope_colon_test
335 struct struct_in_ns2_incomplete_scope_colon_test
337 void incomplete_scope_colon_test ();
341 struct_in_ns2_incomplete_scope_colon_test::incomplete_scope_colon_test ()
345 /* Code for the anon-ns tests. */
349 void __attribute__ ((used
)) anon_ns_function ()
352 struct anon_ns_struct
354 void __attribute__ ((used
)) anon_ns_function ();
357 void __attribute__ ((used
))
358 anon_ns_struct::anon_ns_function ()
362 namespace the_anon_ns_wrapper_ns
367 void __attribute__ ((used
)) anon_ns_function ()
370 struct anon_ns_struct
372 void __attribute__ ((used
)) anon_ns_function ();
375 void __attribute__ ((used
))
376 anon_ns_struct::anon_ns_function ()
380 } /* the_anon_ns_wrapper_ns */
382 /* Code for the global-ns-scope-op tests. */
384 void global_ns_scope_op_function ()
388 /* Add a function with the same name to a namespace. We want to test
389 that "b ::global_ns_function" does NOT select it. */
390 namespace the_global_ns_scope_op_ns
392 void global_ns_scope_op_function ()
397 /* Code for the ambiguous-prefix tests. */
399 /* Create a few functions/methods with the same "ambiguous_prefix_"
400 prefix. They in different scopes, but "b ambiguous_prefix_<tab>"
401 should list them all, and figure out the LCD is
402 ambiguous_prefix_. */
404 void ambiguous_prefix_global_func ()
408 namespace the_ambiguous_prefix_ns
410 void ambiguous_prefix_ns_func ()
415 struct the_ambiguous_prefix_struct
417 void ambiguous_prefix_method ();
421 the_ambiguous_prefix_struct::ambiguous_prefix_method ()
425 /* Code for the function-labels test. */
428 function_with_labels (int i
)
442 /* Code for the no-data-symbols and if-expression tests. */
446 int another_data
= 0;
448 /* A function that has a same "code" prefix as the global above. We
449 want to ensure that completing on "b code" doesn't offer the data
456 /* Code for the operator< tests. */
463 bool operator<(foo_enum lhs
, foo_enum rhs
)
469 /* Code for the in-source-file-unconstrained /
470 in-source-file-ambiguous tests. */
473 file_constrained_test_cpls_function (int i
)
491 template2_struct_inst
.template2_fn
<int, int> ();
492 template_struct_int
.template_overload_fn(0);
493 template_struct_long
.template_overload_fn(0);
494 template_function_foo ();