3ad12b896c1e32f833ac578e1e293fde60546031
3 /* This test script is part of GDB, the GNU debugger.
5 Copyright 1993, 1994, 1997, 1998, 1999, 2003, 2004,
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 // Pls try the following program on virtual functions and try to do print on
23 // most of the code in main(). Almost none of them works !
26 // The inheritance structure is:
50 class V
: public VA
, public VB
58 class A
: virtual public V
74 class C
: public virtual V
86 class D
: public AD
, virtual public V
96 class E
: public B
, virtual public V
, public D
, public C
151 extern "C" int printf(const char *, ...);
154 int failed_count
= 0;
156 #define TEST(EXPR, EXPECTED) \
158 if (ret != EXPECTED) {\
159 printf("Failed %s is %d, should be %d!\n", #EXPR, ret, EXPECTED); \
170 TEST(pDe
->vg(), 202);
171 TEST(pADe
->vg(), 202);
172 TEST(pDd
->vg(), 101);
174 TEST(pEe
->vvb(), 411);
176 TEST(pVB
->vvb(), 407);
178 TEST(pBe
->vvb(), 411);
179 TEST(pDe
->vvb(), 411);
181 TEST(pEe
->vd(), 282);
182 TEST(pEe
->fvb(), 311);
184 TEST(pEe
->D::vg(), 102);
185 printf("Did %d tests, of which %d failed.\n", all_count
, failed_count
);
189 void set_debug_traps();
210 int A::f() {return 1;}
211 int B::f() {return 2;}
213 int E::f() {return 20;}
214 int D::vg() {return 100+d
;}
215 int E::vg() {return 200+d
;}
216 int V::f() {return 600+w
;}
217 int V::vv() {return 400+w
;}
218 int E::vv() {return 450+w
;}
219 int D::fd() {return 250+d
;}
220 int D::vd() {return 280+d
;}
221 int VB::fvb() {return 300+vb
;}
222 int VB::vvb() {return 400+vb
;}