]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/derivation.cc
PR 15519
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / derivation.cc
CommitLineData
8dea366b
KS
1/* This testcase is part of GDB, the GNU debugger.
2
28e7fd62 3 Copyright 2003-2013 Free Software Foundation, Inc.
8dea366b
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
69fc87c2
DE
19extern void foo2 (); /* from derivation2.cc */
20
8dea366b
KS
21namespace N {
22 typedef double value_type;
23 struct Base { typedef int value_type; };
24 struct Derived : public Base {
25 void doit (void) const {
26 int i = 3;
27
28 while (i > 0)
29 --i;
30 }
31 };
32}
33
c906108c
SS
34class A {
35public:
8dea366b
KS
36 typedef int value_type;
37 value_type a;
38 value_type aa;
c906108c
SS
39
40 A()
41 {
42 a=1;
43 aa=2;
44 }
8dea366b
KS
45 value_type afoo();
46 value_type foo();
c906108c
SS
47};
48
49
50
51class B {
52public:
8dea366b
KS
53 A::value_type b;
54 A::value_type bb;
c906108c
SS
55
56 B()
57 {
58 b=3;
59 bb=4;
60 }
8dea366b
KS
61 A::value_type bfoo();
62 A::value_type foo();
c906108c
SS
63
64};
65
66
67
68class C {
69public:
70 int c;
71 int cc;
72
73 C()
74 {
75 c=5;
76 cc=6;
77 }
78 int cfoo();
79 int foo();
80
81};
82
83
84
85class D : private A, public B, protected C {
86public:
8dea366b
KS
87 value_type d;
88 value_type dd;
c906108c
SS
89
90 D()
91 {
92 d =7;
93 dd=8;
94 }
8dea366b
KS
95 value_type dfoo();
96 value_type foo();
c906108c
SS
97
98};
99
100
101class E : public A, B, protected C {
102public:
8dea366b
KS
103 value_type e;
104 value_type ee;
c906108c
SS
105
106 E()
107 {
108 e =9;
109 ee=10;
110 }
8dea366b
KS
111 value_type efoo();
112 value_type foo();
c906108c
SS
113
114};
115
116
117class F : A, public B, C {
118public:
8dea366b
KS
119 value_type f;
120 value_type ff;
c906108c
SS
121
122 F()
123 {
124 f =11;
125 ff=12;
126 }
8dea366b
KS
127 value_type ffoo();
128 value_type foo();
c906108c
SS
129
130};
131
132class G : private A, public B, protected C {
133public:
134 int g;
135 int gg;
136 int a;
137 int b;
138 int c;
139
140 G()
141 {
142 g =13;
143 gg =14;
144 a=15;
145 b=16;
146 c=17;
147
148 }
149 int gfoo();
150 int foo();
151
152};
153
8dea366b
KS
154class Z : public A
155{
156public:
157 typedef float value_type;
158 value_type z;
159};
160
161class ZZ : public Z
162{
163public:
164 value_type zz;
165};
166
7977e5d2
TT
167class V_base
168{
169public:
170 virtual void m();
171 int base;
172};
173
174void
175V_base::m()
176{
177}
c906108c 178
7977e5d2
TT
179class V_inter : public virtual V_base
180{
181public:
182 virtual void f();
183 int inter;
184};
185
186void
187V_inter::f()
188{
189}
190
191class V_derived : public V_inter
192{
193public:
194 double x;
195};
c906108c 196
7977e5d2 197V_derived vderived;
c906108c 198
8dea366b 199A::value_type A::afoo() {
c906108c
SS
200 return 1;
201}
202
8dea366b 203A::value_type B::bfoo() {
c906108c
SS
204 return 2;
205}
206
8dea366b 207A::value_type C::cfoo() {
c906108c
SS
208 return 3;
209}
210
8dea366b 211D::value_type D::dfoo() {
c906108c
SS
212 return 4;
213}
214
8dea366b 215E::value_type E::efoo() {
c906108c
SS
216 return 5;
217}
218
8dea366b 219F::value_type F::ffoo() {
c906108c
SS
220 return 6;
221}
222
223int G::gfoo() {
224 return 77;
225}
226
8dea366b 227A::value_type A::foo()
c906108c
SS
228{
229 return 7;
230
231}
232
8dea366b 233A::value_type B::foo()
c906108c
SS
234{
235 return 8;
236
237}
238
8dea366b 239A::value_type C::foo()
c906108c
SS
240{
241 return 9;
242
243}
244
8dea366b 245D::value_type D::foo()
c906108c
SS
246{
247 return 10;
248
249}
250
8dea366b 251E::value_type E::foo()
c906108c
SS
252{
253 return 11;
254
255}
256
8dea366b 257F::value_type F::foo()
c906108c
SS
258{
259 return 12;
260
261}
262
263int G::foo()
264{
265 return 13;
266
267}
268
269
270void marker1()
271{
272}
273
274
275int main(void)
276{
277
278 A a_instance;
279 B b_instance;
280 C c_instance;
281 D d_instance;
282 E e_instance;
283 F f_instance;
284 G g_instance;
8dea366b
KS
285 Z z_instance;
286 ZZ zz_instance;
287
93201743 288 marker1(); // marker1-returns-here
c906108c 289
93201743 290 a_instance.a = 20; // marker1-returns-here
c906108c
SS
291 a_instance.aa = 21;
292 b_instance.b = 22;
293 b_instance.bb = 23;
294 c_instance.c = 24;
295 c_instance.cc = 25;
296 d_instance.d = 26;
297 d_instance.dd = 27;
298 e_instance.e = 28;
299 e_instance.ee =29;
300 f_instance.f =30;
301 f_instance.ff =31;
8dea366b
KS
302 g_instance.g = 32;
303 g_instance.gg = 33;
304 z_instance.z = 34.0;
305 zz_instance.zz = 35.0;
306
307 N::Derived dobj;
308 N::Derived::value_type d = 1;
309 N::value_type n = 3.0;
310 dobj.doit ();
69fc87c2 311 foo2 ();
c906108c
SS
312 return 0;
313
314}