1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 2003-2013 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 extern void foo2 (); /* from derivation2.cc */
20
21 namespace N {
22 typedef double value_type;
23 struct Base { typedef int value_type; };
24 struct Derived : public Base {
doitN::Derived25 void doit (void) const {
26 int i = 3;
27
28 while (i > 0)
29 --i;
30 }
31 };
32 }
33
34 class A {
35 public:
36 typedef int value_type;
37 value_type a;
38 value_type aa;
39
A()40 A()
41 {
42 a=1;
43 aa=2;
44 }
45 value_type afoo();
46 value_type foo();
47 };
48
49
50
51 class B {
52 public:
53 A::value_type b;
54 A::value_type bb;
55
B()56 B()
57 {
58 b=3;
59 bb=4;
60 }
61 A::value_type bfoo();
62 A::value_type foo();
63
64 };
65
66
67
68 class C {
69 public:
70 int c;
71 int cc;
72
C()73 C()
74 {
75 c=5;
76 cc=6;
77 }
78 int cfoo();
79 int foo();
80
81 };
82
83
84
85 class D : private A, public B, protected C {
86 public:
87 value_type d;
88 value_type dd;
89
D()90 D()
91 {
92 d =7;
93 dd=8;
94 }
95 value_type dfoo();
96 value_type foo();
97
98 };
99
100
101 class E : public A, B, protected C {
102 public:
103 value_type e;
104 value_type ee;
105
E()106 E()
107 {
108 e =9;
109 ee=10;
110 }
111 value_type efoo();
112 value_type foo();
113
114 };
115
116
117 class F : A, public B, C {
118 public:
119 value_type f;
120 value_type ff;
121
F()122 F()
123 {
124 f =11;
125 ff=12;
126 }
127 value_type ffoo();
128 value_type foo();
129
130 };
131
132 class G : private A, public B, protected C {
133 public:
134 int g;
135 int gg;
136 int a;
137 int b;
138 int c;
139
G()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
154 class Z : public A
155 {
156 public:
157 typedef float value_type;
158 value_type z;
159 };
160
161 class ZZ : public Z
162 {
163 public:
164 value_type zz;
165 };
166
167 class V_base
168 {
169 public:
170 virtual void m();
171 int base;
172 };
173
174 void
m()175 V_base::m()
176 {
177 }
178
179 class V_inter : public virtual V_base
180 {
181 public:
182 virtual void f();
183 int inter;
184 };
185
186 void
f()187 V_inter::f()
188 {
189 }
190
191 class V_derived : public V_inter
192 {
193 public:
194 double x;
195 };
196
197 V_derived vderived;
198
afoo()199 A::value_type A::afoo() {
200 return 1;
201 }
202
bfoo()203 A::value_type B::bfoo() {
204 return 2;
205 }
206
cfoo()207 A::value_type C::cfoo() {
208 return 3;
209 }
210
dfoo()211 D::value_type D::dfoo() {
212 return 4;
213 }
214
efoo()215 E::value_type E::efoo() {
216 return 5;
217 }
218
ffoo()219 F::value_type F::ffoo() {
220 return 6;
221 }
222
gfoo()223 int G::gfoo() {
224 return 77;
225 }
226
foo()227 A::value_type A::foo()
228 {
229 return 7;
230
231 }
232
foo()233 A::value_type B::foo()
234 {
235 return 8;
236
237 }
238
foo()239 A::value_type C::foo()
240 {
241 return 9;
242
243 }
244
foo()245 D::value_type D::foo()
246 {
247 return 10;
248
249 }
250
foo()251 E::value_type E::foo()
252 {
253 return 11;
254
255 }
256
foo()257 F::value_type F::foo()
258 {
259 return 12;
260
261 }
262
foo()263 int G::foo()
264 {
265 return 13;
266
267 }
268
269
marker1()270 void marker1()
271 {
272 }
273
274
main(void)275 int 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;
285 Z z_instance;
286 ZZ zz_instance;
287
288 marker1(); // marker1-returns-here
289
290 a_instance.a = 20; // marker1-returns-here
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;
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 ();
311 foo2 ();
312 return 0;
313
314 }
315