3 /* This test script is part of GDB, the GNU debugger.
5 Copyright (C) 1993-2018 Free Software Foundation, Inc.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
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
;}