OSDN Git Service

PR c++/46124
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / torture / pr46287.C
1 // Check that indirect calls to thunks do not lead to errors.
2 // { dg-do run }
3
4 extern "C" void abort ();
5
6 class A
7 {
8 public:
9   virtual void foo () {abort();}
10 };
11
12 class B : public A
13 {
14 public:
15   int z;
16   virtual void foo () {abort();}
17 };
18
19 class C : public A
20 {
21 public:
22   void *a[32];
23   unsigned long b;
24   long c[32];
25
26   virtual void foo () {abort();}
27 };
28
29 class D : public C, public B
30 {
31 public:
32   D () : C(), B()
33   {
34     int i;
35     for (i = 0; i < 32; i++)
36       {
37         a[i] = (void *) 0;
38         c[i] = 0;
39       }
40     b = 0xaaaa;
41   }
42
43   virtual void foo ();
44 };
45
46 void D::foo()
47 {
48   if (b != 0xaaaa)
49     abort();
50 }
51
52 static inline void bar (B &b)
53 {
54
55   b.foo ();
56 }
57
58 int main()
59 {
60   int i;
61   D d;
62
63   for (i = 0; i < 5000; i++)
64     bar (d);
65   return 0;
66 }