Commit | Line | Data |
---|---|---|
8dea366b KS |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
32d0add0 | 3 | Copyright 2003-2015 Free Software Foundation, Inc. |
8dea366b KS |
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 | |
47d48711 | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
8dea366b | 17 | |
69fc87c2 DE |
18 | extern void foo2 (); /* from derivation2.cc */ |
19 | ||
8dea366b KS |
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; | |
26 | ||
27 | while (i > 0) | |
28 | --i; | |
29 | } | |
30 | }; | |
31 | } | |
32 | ||
c906108c SS |
33 | class A { |
34 | public: | |
8dea366b KS |
35 | typedef int value_type; |
36 | value_type a; | |
37 | value_type aa; | |
c906108c SS |
38 | |
39 | A() | |
40 | { | |
41 | a=1; | |
42 | aa=2; | |
43 | } | |
8dea366b KS |
44 | value_type afoo(); |
45 | value_type foo(); | |
c906108c SS |
46 | }; |
47 | ||
48 | ||
49 | ||
50 | class B { | |
51 | public: | |
8dea366b KS |
52 | A::value_type b; |
53 | A::value_type bb; | |
c906108c SS |
54 | |
55 | B() | |
56 | { | |
57 | b=3; | |
58 | bb=4; | |
59 | } | |
8dea366b KS |
60 | A::value_type bfoo(); |
61 | A::value_type foo(); | |
c906108c SS |
62 | |
63 | }; | |
64 | ||
65 | ||
66 | ||
67 | class C { | |
68 | public: | |
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 | ||
84 | class D : private A, public B, protected C { | |
85 | public: | |
8dea366b KS |
86 | value_type d; |
87 | value_type dd; | |
c906108c SS |
88 | |
89 | D() | |
90 | { | |
91 | d =7; | |
92 | dd=8; | |
93 | } | |
8dea366b KS |
94 | value_type dfoo(); |
95 | value_type foo(); | |
c906108c SS |
96 | |
97 | }; | |
98 | ||
99 | ||
100 | class E : public A, B, protected C { | |
101 | public: | |
8dea366b KS |
102 | value_type e; |
103 | value_type ee; | |
c906108c SS |
104 | |
105 | E() | |
106 | { | |
107 | e =9; | |
108 | ee=10; | |
109 | } | |
8dea366b KS |
110 | value_type efoo(); |
111 | value_type foo(); | |
c906108c SS |
112 | |
113 | }; | |
114 | ||
115 | ||
116 | class F : A, public B, C { | |
117 | public: | |
8dea366b KS |
118 | value_type f; |
119 | value_type ff; | |
c906108c SS |
120 | |
121 | F() | |
122 | { | |
123 | f =11; | |
124 | ff=12; | |
125 | } | |
8dea366b KS |
126 | value_type ffoo(); |
127 | value_type foo(); | |
c906108c SS |
128 | |
129 | }; | |
130 | ||
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; | |
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 | ||
8dea366b KS |
153 | class Z : public A |
154 | { | |
155 | public: | |
156 | typedef float value_type; | |
157 | value_type z; | |
158 | }; | |
159 | ||
160 | class ZZ : public Z | |
161 | { | |
162 | public: | |
163 | value_type zz; | |
164 | }; | |
165 | ||
7977e5d2 TT |
166 | class V_base |
167 | { | |
168 | public: | |
169 | virtual void m(); | |
170 | int base; | |
171 | }; | |
172 | ||
173 | void | |
174 | V_base::m() | |
175 | { | |
176 | } | |
c906108c | 177 | |
7977e5d2 TT |
178 | class V_inter : public virtual V_base |
179 | { | |
180 | public: | |
181 | virtual void f(); | |
182 | int inter; | |
183 | }; | |
184 | ||
185 | void | |
186 | V_inter::f() | |
187 | { | |
188 | } | |
189 | ||
190 | class V_derived : public V_inter | |
191 | { | |
192 | public: | |
193 | double x; | |
194 | }; | |
c906108c | 195 | |
7977e5d2 | 196 | V_derived vderived; |
c906108c | 197 | |
8dea366b | 198 | A::value_type A::afoo() { |
c906108c SS |
199 | return 1; |
200 | } | |
201 | ||
8dea366b | 202 | A::value_type B::bfoo() { |
c906108c SS |
203 | return 2; |
204 | } | |
205 | ||
8dea366b | 206 | A::value_type C::cfoo() { |
c906108c SS |
207 | return 3; |
208 | } | |
209 | ||
8dea366b | 210 | D::value_type D::dfoo() { |
c906108c SS |
211 | return 4; |
212 | } | |
213 | ||
8dea366b | 214 | E::value_type E::efoo() { |
c906108c SS |
215 | return 5; |
216 | } | |
217 | ||
8dea366b | 218 | F::value_type F::ffoo() { |
c906108c SS |
219 | return 6; |
220 | } | |
221 | ||
222 | int G::gfoo() { | |
223 | return 77; | |
224 | } | |
225 | ||
8dea366b | 226 | A::value_type A::foo() |
c906108c SS |
227 | { |
228 | return 7; | |
229 | ||
230 | } | |
231 | ||
8dea366b | 232 | A::value_type B::foo() |
c906108c SS |
233 | { |
234 | return 8; | |
235 | ||
236 | } | |
237 | ||
8dea366b | 238 | A::value_type C::foo() |
c906108c SS |
239 | { |
240 | return 9; | |
241 | ||
242 | } | |
243 | ||
8dea366b | 244 | D::value_type D::foo() |
c906108c SS |
245 | { |
246 | return 10; | |
247 | ||
248 | } | |
249 | ||
8dea366b | 250 | E::value_type E::foo() |
c906108c SS |
251 | { |
252 | return 11; | |
253 | ||
254 | } | |
255 | ||
8dea366b | 256 | F::value_type F::foo() |
c906108c SS |
257 | { |
258 | return 12; | |
259 | ||
260 | } | |
261 | ||
262 | int G::foo() | |
263 | { | |
264 | return 13; | |
265 | ||
266 | } | |
267 | ||
268 | ||
269 | void marker1() | |
270 | { | |
271 | } | |
272 | ||
273 | ||
274 | int 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; | |
8dea366b KS |
284 | Z z_instance; |
285 | ZZ zz_instance; | |
286 | ||
93201743 | 287 | marker1(); // marker1-returns-here |
c906108c | 288 | |
93201743 | 289 | a_instance.a = 20; // marker1-returns-here |
c906108c SS |
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; | |
8dea366b KS |
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 (); | |
69fc87c2 | 310 | foo2 (); |
c906108c SS |
311 | return 0; |
312 | ||
313 | } |