Update years in copyright notice for the GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / meth-typedefs.cc
CommitLineData
59cde39c
KS
1/* This testcase is part of GDB, the GNU debugger.
2
28e7fd62 3 Copyright 2011-2013 Free Software Foundation, Inc.
59cde39c
KS
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 Contributed by Red Hat, originally written by Keith Seitz. */
19
20#include <stdlib.h>
21
22typedef const char* const* my_type;
23typedef int my_type_2;
24typedef my_type my_other_type;
25typedef my_type_2 my_other_type_2;
26typedef unsigned long CORE_ADDR;
27typedef enum {E_A, E_B, E_C} anon_enum;
28typedef struct {int a; char b;} anon_struct;
29typedef union {int a; char b;} anon_union;
30typedef anon_enum aenum;
31typedef anon_struct astruct;
32typedef anon_union aunion;
33
34typedef void (*fptr1) (my_other_type);
35typedef void (*fptr2) (fptr1, my_other_type_2);
36typedef void (*fptr3) (fptr2, my_other_type);
37typedef void (*fptr4) (anon_enum a, anon_struct const& b, anon_union const*** c);
38
39namespace A
40{
41 class foo
42 {
43 public:
44 foo (void) { }
45 foo (my_other_type a) { } // A::FOO::foo(my_other_type)
46 foo (my_other_type_2 a) { } // A::FOO::foo(my_other_type_2)
47 foo (my_other_type_2 a, const my_other_type b) { } // A::FOO::foo(my_other_type_2, const my_other_type)
48 foo (fptr3) { } // A::FOO::foo(fptr3)
49 foo (fptr1* a) { } // A::FOO::foo(fptr1*)
50 foo (CORE_ADDR (*) [10]) { } // A::FOO::foo(CORE_ADDR (*) [10])
51 foo (aenum a, astruct const& b, aunion const*** c) { } // A::FOO::foo(aenum, astruct const&, aunion const***)
52
53 void test (my_other_type a) { } // A::FOO::test(my_other_type)
54 void test (my_other_type_2 a) { } // A::FOO::test(my_other_type_2)
55 void test (my_other_type_2 a, const my_other_type b) { } // A::FOO::test(my_other_type_2, const my_other_type)
56 void test (fptr3 a) { } // A::FOO::test(fptr3)
57 void test (fptr1* a) { } // A::FOO::test(fptr1*)
58 void test (CORE_ADDR (*) [10]) { } // A::FOO::test(CORE_ADDR (*) [10])
59 void test (aenum a, astruct const& b, aunion const*** c) { }; // A::FOO::test(aenum, astruct const&, aunion const***)
60 };
61
62 typedef foo FOO;
63};
64
65namespace B
66{
67 void
68 test (my_other_type foo) { } // B::test(my_other_type)
69
70 void
71 test (aenum a, astruct const& b, aunion const*** c) { } // B::test(aenum, astruct const&, aunion const***)
72
73 template <typename T1, typename T2>
74 void test (T1 a, T2 b) { } // B::test (T1, T2)
75
76 template <>
77 void test (my_other_type foo, my_other_type_2) { } // B::test<my_other_type, my_other_type_2>(my_other_type, my_other_type_2)
78};
79
80namespace a
81{
82 namespace b
83 {
84 namespace c
85 {
86 namespace d
87 {
88 class bar { };
89 }
90 }
91
92 typedef c::d::bar BAR;
93 }
94}
95
96typedef a::b::BAR _BAR_;
97
98template <typename T1, typename T2>
99void test (T1 a, T2 b) {} // test (T1, T2)
100
101template <>
102void test (my_other_type foo, my_other_type_2) { } // test<my_other_type, my_other_type_2>(my_other_type, my_other_type_2)
103
104void
105test (my_other_type foo) { } // test(my_other_type)
106
107void
108test (_BAR_ &b) { } // test(_BAR_&)
109
110void
111test (aenum a, astruct const& b, aunion const*** c) { } // test(aenum, astruct const&, aunion const***)
112
113int
114main (void)
115{
116 A::FOO my_foo;
117 fptr1 fptr;
118 astruct as = { 0, 0 };
119 aunion const au = { 0 };
120 aunion const* aup = &au;
121 aunion const** aupp = &aup;
122 aunion const*** auppp = &aupp;
123
124 my_foo.test (static_cast<my_other_type> (NULL));
125 my_foo.test (0);
126 my_foo.test (0, static_cast<my_type> (NULL));
127 my_foo.test (static_cast<fptr3> (NULL));
128 my_foo.test (&fptr);
129 my_foo.test (static_cast<CORE_ADDR (*) [10]> (0));
130 my_foo.test (E_A, as, auppp);
131
132 B::test (static_cast<my_other_type> (NULL));
133 B::test (static_cast<my_other_type> (NULL), 0);
134 B::test (E_A, as, auppp);
135
136 test (static_cast<my_other_type> (NULL));
137 test<my_other_type, my_other_type_2> (static_cast<my_other_type> (NULL), 0);
138 test (E_A, as, auppp);
139
140 A::foo a (static_cast<my_other_type> (NULL));
141 A::foo b (0);
142 A::foo c (0, static_cast<my_other_type> (NULL));
143 A::foo d (static_cast<fptr3> (NULL));
144 A::foo e (&fptr);
145 A::foo f (static_cast<CORE_ADDR (*) [10]> (0));
146 A::foo g (E_A, as, auppp);
147
148 fptr4 f4;
149
150 return 0;
151}
This page took 0.191122 seconds and 4 git commands to generate.