1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2017-2019 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) \
60 overload2_function (ARG1) \
63 struct struct_overload2_test \
65 void overload2_function (ARG2); \
69 struct_overload2_test::overload2_function (ARG2) \
72 /* In the global namespace. */
73 GEN_OVERLOAD2_FUNCTIONS( overload2_arg1
, overload2_arg2
)
77 /* In an anonymous namespace. */
78 GEN_OVERLOAD2_FUNCTIONS (overload2_arg3
, overload2_arg4
)
81 namespace ns_overload2_test
84 GEN_OVERLOAD2_FUNCTIONS (overload2_arg5
, overload2_arg6
)
88 /* In a nested anonymous namespace. */
89 GEN_OVERLOAD2_FUNCTIONS (overload2_arg7
, overload2_arg8
)
91 namespace ns_overload2_test
93 /* In a nested namespace. */
94 GEN_OVERLOAD2_FUNCTIONS (overload2_arg9
, overload2_arga
)
99 /* Code for the overload-3 test. */
101 #define GEN_OVERLOAD3_FUNCTIONS(ARG1, ARG2) \
103 overload3_function (ARG1) \
106 overload3_function (ARG2) \
109 struct struct_overload3_test \
111 void overload3_function (ARG1); \
112 void overload3_function (ARG2); \
116 struct_overload3_test::overload3_function (ARG1) \
119 struct_overload3_test::overload3_function (ARG2) \
122 /* In the global namespace. */
123 GEN_OVERLOAD3_FUNCTIONS (int, long)
127 /* In an anonymous namespace. */
128 GEN_OVERLOAD3_FUNCTIONS (int, long)
131 namespace ns_overload3_test
133 /* In a namespace. */
134 GEN_OVERLOAD3_FUNCTIONS (int, long)
138 /* In a nested anonymous namespace. */
139 GEN_OVERLOAD3_FUNCTIONS (int, long)
141 namespace ns_overload3_test
143 /* In a nested namespace. */
144 GEN_OVERLOAD3_FUNCTIONS (int, long)
149 /* Code for the template-overload tests. */
151 template <typename T
>
152 struct template_struct
154 T
template_overload_fn (T
);
157 template <typename T
>
158 T template_struct
<T
>::template_overload_fn (T t
)
163 template_struct
<int> template_struct_int
;
164 template_struct
<long> template_struct_long
;
166 /* Code for the template2-ret-type tests. */
168 template <typename T
>
169 struct template2_ret_type
{};
171 template <typename T
>
172 struct template2_struct
174 template <typename T2
, typename T3
>
175 T
template2_fn (T
= T (), T2 t2
= T2 (), T3 t3
= T3 ());
178 template <typename T
>
179 template <typename T2
, typename T3
>
180 T template2_struct
<T
>::template2_fn (T t
, T2 t2
, T3 t3
)
185 template2_struct
<template2_ret_type
<int> > template2_struct_inst
;
187 /* Code for the const-overload tests. */
189 struct struct_with_const_overload
191 void const_overload_fn ();
192 void const_overload_fn () const;
196 struct_with_const_overload::const_overload_fn ()
200 struct_with_const_overload::const_overload_fn () const
207 /* Code for the incomplete-scope-colon tests. */
209 struct struct_incomplete_scope_colon_test
211 void incomplete_scope_colon_test ();
215 struct_incomplete_scope_colon_test::incomplete_scope_colon_test ()
218 namespace ns_incomplete_scope_colon_test
220 void incomplete_scope_colon_test () {}
223 namespace ns2_incomplete_scope_colon_test
225 struct struct_in_ns2_incomplete_scope_colon_test
227 void incomplete_scope_colon_test ();
231 struct_in_ns2_incomplete_scope_colon_test::incomplete_scope_colon_test ()
235 /* Code for the anon-ns tests. */
239 void anon_ns_function ()
242 struct anon_ns_struct
244 void anon_ns_function ();
248 anon_ns_struct::anon_ns_function ()
252 namespace the_anon_ns_wrapper_ns
257 void anon_ns_function ()
260 struct anon_ns_struct
262 void anon_ns_function ();
266 anon_ns_struct::anon_ns_function ()
270 } /* the_anon_ns_wrapper_ns */
272 /* Code for the global-ns-scope-op tests. */
274 void global_ns_scope_op_function ()
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
282 void global_ns_scope_op_function ()
287 /* Code for the ambiguous-prefix tests. */
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_. */
294 void ambiguous_prefix_global_func ()
298 namespace the_ambiguous_prefix_ns
300 void ambiguous_prefix_ns_func ()
305 struct the_ambiguous_prefix_struct
307 void ambiguous_prefix_method ();
311 the_ambiguous_prefix_struct::ambiguous_prefix_method ()
315 /* Code for the function-labels test. */
318 function_with_labels (int i
)
332 /* Code for the no-data-symbols and if-expression tests. */
336 int another_data
= 0;
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
346 /* Code for the operator< tests. */
353 bool operator<(foo_enum lhs
, foo_enum rhs
)
359 /* Code for the in-source-file-unconstrained /
360 in-source-file-ambiguous tests. */
363 file_constrained_test_cpls_function (int i
)
381 template2_struct_inst
.template2_fn
<int, int> ();
382 template_struct_int
.template_overload_fn(0);
383 template_struct_long
.template_overload_fn(0);