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