1 /* This test script is part of GDB, the GNU debugger.
3 Copyright 1993, 1994, 1997, 1998, 1999, 2003, 2004,
4 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 // Pls try the following program on virtual functions and try to do print on
22 // most of the code in main(). Almost none of them works !
25 // The inheritance structure is:
49 class V
: public VA
, public VB
57 class A
: virtual public V
73 class C
: public virtual V
85 class D
: public AD
, virtual public V
95 class E
: public B
, virtual public V
, public D
, public C
150 extern "C" int printf(const char *, ...);
153 int failed_count
= 0;
155 #define TEST(EXPR, EXPECTED) \
157 if (ret != EXPECTED) {\
158 printf("Failed %s is %d, should be %d!\n", #EXPR, ret, EXPECTED); \
169 TEST(pDe
->vg(), 202);
170 TEST(pADe
->vg(), 202);
171 TEST(pDd
->vg(), 101);
173 TEST(pEe
->vvb(), 411);
175 TEST(pVB
->vvb(), 407);
177 TEST(pBe
->vvb(), 411);
178 TEST(pDe
->vvb(), 411);
180 TEST(pEe
->vd(), 282);
181 TEST(pEe
->fvb(), 311);
183 TEST(pEe
->D::vg(), 102);
184 printf("Did %d tests, of which %d failed.\n", all_count
, failed_count
);
188 void set_debug_traps();
209 int A::f() {return 1;}
210 int B::f() {return 2;}
212 int E::f() {return 20;}
213 int D::vg() {return 100+d
;}
214 int E::vg() {return 200+d
;}
215 int V::f() {return 600+w
;}
216 int V::vv() {return 400+w
;}
217 int E::vv() {return 450+w
;}
218 int D::fd() {return 250+d
;}
219 int D::vd() {return 280+d
;}
220 int VB::fvb() {return 300+vb
;}
221 int VB::vvb() {return 400+vb
;}