PR c++/8888:
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / derivation.cc
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 2003-2004, 2007-2012 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
19 namespace 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
32 class A {
33 public:
34 typedef int value_type;
35 value_type a;
36 value_type aa;
37
38 A()
39 {
40 a=1;
41 aa=2;
42 }
43 value_type afoo();
44 value_type foo();
45 };
46
47
48
49 class B {
50 public:
51 A::value_type b;
52 A::value_type bb;
53
54 B()
55 {
56 b=3;
57 bb=4;
58 }
59 A::value_type bfoo();
60 A::value_type foo();
61
62 };
63
64
65
66 class C {
67 public:
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
83 class D : private A, public B, protected C {
84 public:
85 value_type d;
86 value_type dd;
87
88 D()
89 {
90 d =7;
91 dd=8;
92 }
93 value_type dfoo();
94 value_type foo();
95
96 };
97
98
99 class E : public A, B, protected C {
100 public:
101 value_type e;
102 value_type ee;
103
104 E()
105 {
106 e =9;
107 ee=10;
108 }
109 value_type efoo();
110 value_type foo();
111
112 };
113
114
115 class F : A, public B, C {
116 public:
117 value_type f;
118 value_type ff;
119
120 F()
121 {
122 f =11;
123 ff=12;
124 }
125 value_type ffoo();
126 value_type foo();
127
128 };
129
130 class G : private A, public B, protected C {
131 public:
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
152 class Z : public A
153 {
154 public:
155 typedef float value_type;
156 value_type z;
157 };
158
159 class ZZ : public Z
160 {
161 public:
162 value_type zz;
163 };
164
165 class V_base
166 {
167 public:
168 virtual void m();
169 int base;
170 };
171
172 void
173 V_base::m()
174 {
175 }
176
177 class V_inter : public virtual V_base
178 {
179 public:
180 virtual void f();
181 int inter;
182 };
183
184 void
185 V_inter::f()
186 {
187 }
188
189 class V_derived : public V_inter
190 {
191 public:
192 double x;
193 };
194
195 V_derived vderived;
196
197 A::value_type A::afoo() {
198 return 1;
199 }
200
201 A::value_type B::bfoo() {
202 return 2;
203 }
204
205 A::value_type C::cfoo() {
206 return 3;
207 }
208
209 D::value_type D::dfoo() {
210 return 4;
211 }
212
213 E::value_type E::efoo() {
214 return 5;
215 }
216
217 F::value_type F::ffoo() {
218 return 6;
219 }
220
221 int G::gfoo() {
222 return 77;
223 }
224
225 A::value_type A::foo()
226 {
227 return 7;
228
229 }
230
231 A::value_type B::foo()
232 {
233 return 8;
234
235 }
236
237 A::value_type C::foo()
238 {
239 return 9;
240
241 }
242
243 D::value_type D::foo()
244 {
245 return 10;
246
247 }
248
249 E::value_type E::foo()
250 {
251 return 11;
252
253 }
254
255 F::value_type F::foo()
256 {
257 return 12;
258
259 }
260
261 int G::foo()
262 {
263 return 13;
264
265 }
266
267
268 void marker1()
269 {
270 }
271
272
273 int 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;
283 Z z_instance;
284 ZZ zz_instance;
285
286 marker1(); // marker1-returns-here
287
288 a_instance.a = 20; // marker1-returns-here
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;
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 ();
309 return 0;
310
311 }
312
313
314
This page took 0.053775 seconds and 4 git commands to generate.