]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.hp/virtfun-hp.cc
1 // Pls try the following program on virtual functions and try to do print on
2 // most of the code in main(). Almost none of them works !
5 // The inheritance structure is:
29 class V
: public VA
, public VB
37 class A
: virtual public V
53 class C
: public virtual V
65 class D
: public AD
, virtual public V
75 class E
: public B
, virtual public V
, public D
, public C
130 extern "C" printf(const char *, ...);
133 int failed_count
= 0;
135 #define TEST(EXPR, EXPECTED) \
137 if (ret != EXPECTED) {\
138 printf("Failed %s is %d, should be %d!\n", #EXPR, ret, EXPECTED); \
149 TEST(pDe
->vg(), 202);
150 TEST(pADe
->vg(), 202);
151 TEST(pDd
->vg(), 101);
153 TEST(pEe
->vvb(), 411);
155 TEST(pVB
->vvb(), 407);
157 TEST(pBe
->vvb(), 411);
158 TEST(pDe
->vvb(), 411);
160 TEST(pEe
->vd(), 282);
161 TEST(pEe
->fvb(), 311);
163 TEST(pEe
->D::vg(), 102);
164 printf("Did %d tests, of which %d failed.\n", all_count
, failed_count
);
180 int A::f() {return 1;}
181 int B::f() {return 2;}
183 int E::f() {return 20;}
184 int D::vg() {return 100+d
;}
185 int E::vg() {return 200+d
;}
186 int V::f() {return 600+w
;}
187 int V::vv() {return 400+w
;}
188 int E::vv() {return 450+w
;}
189 int D::fd() {return 250+d
;}
190 int D::vd() {return 280+d
;}
191 int VB::fvb() {return 300+vb
;}
192 int VB::vvb() {return 400+vb
;}