aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp/derivation.cc
blob: cf3f57cfed037606ff57111335f74dc4b1afb323 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
/* This testcase is part of GDB, the GNU debugger.

   Copyright 2003-2018 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

extern void foo2 (); /* from derivation2.cc */

namespace N {
  typedef double value_type;
  struct Base { typedef int value_type; };
  struct Derived : public Base {
    void doit (void) const {
       int i = 3;

       while (i > 0)
         --i;
     }
  };
}

class A {
public:
    typedef int value_type;
    value_type a;
    value_type aa;

    A()
    {
        a=1;
        aa=2;
    }
    value_type afoo();
    value_type foo();
};



class B {
public:
    A::value_type b;
    A::value_type bb;

    B()
    {
        b=3;
        bb=4;
    }
    A::value_type bfoo();
    A::value_type foo();
    
};



class C {
public:
    int c;
    int cc;

    C()
    {
        c=5;
        cc=6;
    }
    int cfoo();
    int foo();
    
};



class D : private A, public B, protected C {
public:
    value_type d;
    value_type dd;

    D()
    {
        d =7;
        dd=8;
    }
    value_type dfoo();
    value_type foo();
    
};


class E : public A, B, protected C {
public:
    value_type e;
    value_type ee;

    E()
    {
        e =9;
        ee=10;
    }
    value_type efoo();
    value_type foo();
    
};


class F : A, public B, C {
public:
    value_type f;
    value_type ff;

    F()
    {
        f =11;
        ff=12;
    }
    value_type ffoo();
    value_type foo();
    
};

class G : private A, public B, protected C {
public:
    int g;
    int gg;
    int a;
    int b;
    int c;

    G()
    {
        g =13;
        gg =14;
        a=15;
        b=16;
        c=17;
        
    }
    int gfoo();
    int foo();
    
};

class Z : public A
{
public:
  typedef float value_type;
  value_type z;
};

class ZZ : public Z
{
public:
  value_type zz;
};

class V_base
{
public:
  virtual void m();
  int base;
};

void
V_base::m()
{
}

class V_inter : public virtual V_base
{
public:
  virtual void f();
  int inter;
};

void
V_inter::f()
{
}

class V_derived : public V_inter
{
public:
  double x;
};

V_derived vderived;

A::value_type A::afoo() {
    return 1;
}

A::value_type B::bfoo() {
    return 2;
}

A::value_type C::cfoo() {
    return 3;
}

D::value_type D::dfoo() {
    return 4;
}

E::value_type E::efoo() {
    return 5;
}

F::value_type F::ffoo() {
    return 6;
}

int G::gfoo() {
    return 77;
}

A::value_type A::foo()
{
    return 7;
    
}

A::value_type B::foo()
{
    return 8;
    
}

A::value_type C::foo()
{
    return 9;
    
}

D::value_type D::foo()
{
    return 10;
    
}

E::value_type E::foo()
{
    return 11;
    
}

F::value_type F::foo()
{
    return 12;
    
}

int G::foo()
{
    return 13;
    
}


void marker1()
{
}


int main(void)
{

    A a_instance;
    B b_instance;
    C c_instance;
    D d_instance;
    E e_instance;
    F f_instance;
    G g_instance;
    Z z_instance;
    ZZ zz_instance;

    marker1(); // marker1-returns-here
    
    a_instance.a = 20; // marker1-returns-here
    a_instance.aa = 21;
    b_instance.b = 22;
    b_instance.bb = 23;
    c_instance.c = 24;
    c_instance.cc = 25;
    d_instance.d = 26;
    d_instance.dd = 27;
    e_instance.e = 28;
    e_instance.ee =29;
    f_instance.f =30;
    f_instance.ff =31;
    g_instance.g = 32;
    g_instance.gg = 33;
    z_instance.z = 34.0;
    zz_instance.zz = 35.0;

    N::Derived dobj;
    N::Derived::value_type d = 1;
    N::value_type n = 3.0;
    dobj.doit ();
    foo2 ();
    return 0;
    
}