dwarf_lang_to_enum_language: Map new DWARF5 constants
[binutils-gdb.git] / gdb / testsuite / gdb.cp / derivation.cc
blob72292572a0fc2d72941bdeece5939fa0c6bb5c1a
1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2003-2024 Free Software Foundation, Inc.
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.
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.
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/>. */
18 extern void foo2 (); /* from derivation2.cc */
20 namespace 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;
27 while (i > 0)
28 --i;
33 class A {
34 public:
35 typedef int value_type;
36 value_type a;
37 value_type aa;
39 A()
41 a=1;
42 aa=2;
44 value_type afoo();
45 value_type foo();
50 class B {
51 public:
52 A::value_type b;
53 A::value_type bb;
55 B()
57 b=3;
58 bb=4;
60 A::value_type bfoo();
61 A::value_type foo();
67 class C {
68 public:
69 int c;
70 int cc;
72 C()
74 c=5;
75 cc=6;
77 int cfoo();
78 int foo();
84 class D : private A, public B, protected C {
85 public:
86 value_type d;
87 value_type dd;
89 D()
91 d =7;
92 dd=8;
94 value_type dfoo();
95 value_type foo();
100 class E : public A, B, protected C {
101 public:
102 value_type e;
103 value_type ee;
107 e =9;
108 ee=10;
110 value_type efoo();
111 value_type foo();
116 class F : A, public B, C {
117 public:
118 value_type f;
119 value_type ff;
123 f =11;
124 ff=12;
126 value_type ffoo();
127 value_type foo();
131 class G : private A, public B, protected C {
132 public:
133 int g;
134 int gg;
135 int a;
136 int b;
137 int c;
141 g =13;
142 gg =14;
143 a=15;
144 b=16;
145 c=17;
148 int gfoo();
149 int foo();
153 class Z : public A
155 public:
156 typedef float value_type;
157 value_type z;
160 class ZZ : public Z
162 public:
163 value_type zz;
166 class V_base
168 public:
169 virtual void m();
170 int base;
173 void
174 V_base::m()
178 class V_inter : public virtual V_base
180 public:
181 virtual void f();
182 int inter;
185 void
186 V_inter::f()
190 class V_derived : public V_inter
192 public:
193 double x;
196 V_derived vderived;
198 A::value_type A::afoo() {
199 return 1;
202 A::value_type B::bfoo() {
203 return 2;
206 A::value_type C::cfoo() {
207 return 3;
210 D::value_type D::dfoo() {
211 return 4;
214 E::value_type E::efoo() {
215 return 5;
218 F::value_type F::ffoo() {
219 return 6;
222 int G::gfoo() {
223 return 77;
226 A::value_type A::foo()
228 return 7;
232 A::value_type B::foo()
234 return 8;
238 A::value_type C::foo()
240 return 9;
244 D::value_type D::foo()
246 return 10;
250 E::value_type E::foo()
252 return 11;
256 F::value_type F::foo()
258 return 12;
262 int G::foo()
264 return 13;
269 void marker1()
274 int main(void)
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;
287 marker1(); // marker1-returns-here
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;
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;