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