]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.cc
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.linespec / cp-replace-typedefs-ns-template.cc
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 2019-2022 Free Software Foundation, Inc.
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 namespace NS1 {
19
20 namespace NS2 {
21
22 struct object
23 {
24 object ()
25 {
26 }
27 };
28
29 typedef object *object_p;
30
31 template<typename T>
32 struct Templ1
33 {
34 explicit Templ1 (object_p)
35 {
36 }
37
38 template<typename I>
39 static void
40 static_method (object_p)
41 {
42 }
43 };
44
45 template<typename T, typename U>
46 struct Templ2
47 {
48 explicit Templ2 (object_p)
49 {
50 }
51
52 template<typename I>
53 static void
54 static_method (object_p)
55 {
56 }
57 };
58
59 template<typename T> using AliasTempl = Templ2<int, T>;
60
61 typedef Templ1<int> int_Templ1_t;
62
63 void
64 object_p_func (object_p)
65 {
66 }
67
68 void
69 int_Templ1_t_func (int_Templ1_t *)
70 {
71 }
72
73 } // namespace NS2
74
75 } // namespace NS1
76
77 /* These typedefs have the same name as some of the components within
78 NS1 that they alias to, on purpose, to try to confuse GDB and cause
79 recursion. */
80 using NS2 = int;
81 using object = NS1::NS2::object;
82 using Templ1 = NS1::NS2::Templ1<unsigned>;
83 using Templ2 = NS1::NS2::Templ2<long, long>;
84 using AliasTempl = NS1::NS2::AliasTempl<int>;
85
86 NS2 ns2_int = 0;
87 object obj;
88 Templ1 templ1 (0);
89 NS1::NS2::int_Templ1_t int_templ1 (0);
90 AliasTempl alias (0);
91
92 int
93 main ()
94 {
95 NS1::NS2::Templ1<int>::static_method<int> (0);
96 NS1::NS2::AliasTempl<int>::static_method<int> (0);
97 NS1::NS2::object_p_func (0);
98 NS1::NS2::int_Templ1_t_func (0);
99
100 return 0;
101 }