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 3 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, see <http://www.gnu.org/licenses/>.
20 // Pls try the following program on virtual functions and try to do print on
21 // most of the code in main(). Almost none of them works !
24 // The inheritance structure is:
48 class V : public VA, public VB
56 class A : virtual public V
72 class C : public virtual V
84 class D : public AD, virtual public V
94 class E : public B, virtual public V, public D, public C
149 extern "C" int printf(const char *, ...);
152 int failed_count = 0;
154 #define TEST(EXPR, EXPECTED) \
156 if (ret != EXPECTED) {\
157 printf("Failed %s is %d, should be %d!\n", #EXPR, ret, EXPECTED); \
168 TEST(pDe->vg(), 202);
169 TEST(pADe->vg(), 202);
170 TEST(pDd->vg(), 101);
172 TEST(pEe->vvb(), 411);
174 TEST(pVB->vvb(), 407);
176 TEST(pBe->vvb(), 411);
177 TEST(pDe->vvb(), 411);
179 TEST(pEe->vd(), 282);
180 TEST(pEe->fvb(), 311);
182 TEST(pEe->D::vg(), 102);
183 printf("Did %d tests, of which %d failed.\n", all_count, failed_count);
187 void set_debug_traps();
208 int A::f() {return 1;}
209 int B::f() {return 2;}
211 int E::f() {return 20;}
212 int D::vg() {return 100+d;}
213 int E::vg() {return 200+d;}
214 int V::f() {return 600+w;}
215 int V::vv() {return 400+w;}
216 int E::vv() {return 450+w;}
217 int D::fd() {return 250+d;}
218 int D::vd() {return 280+d;}
219 int VB::fvb() {return 300+vb;}
220 int VB::vvb() {return 400+vb;}