Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / g++.old-deja / g++.abi / vtable.C
blobb93710af72585756285af142a65a24b6457ea165
1 // { dg-do run  }
2 // { dg-options "-fno-strict-aliasing" }
3 // Test various aspects of vtable layout.
4 // Origin: Mark Mitchell <mark@codesourcery.com>
6 #if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
8 struct S0
10   virtual void h ()
11   {
12   }
14   int k;
18 struct S1 
20   virtual void f () 
21   {
22   }
24   int i;
27 struct S2 : virtual public S0
29   virtual void g ()
30   {
31   }
33   int j;
36 struct S3 
38   virtual void k () 
39   {
40   }
42   int l;
45 struct S4 : public virtual S1, public S2, public S3
49 inline void* vtable (void *object)
51   // The vptr is always the first part of the object.
52   return * (void **) object;
55 int main ()
57   // The vtable layout order for S4 should consist of S4's primary
58   // vtable (shared with S2), followed by the vtable for S3 (because
59   // it is a non-virtual base).  Then, these should be followed by the
60   // the vtables for S1 and S0, which are virtual.
61   S4 s4;
62   S0 *s0 = &s4;
63   S1 *s1 = &s4;
64   S2 *s2 = &s4;
65   S3 *s3 = &s4;
66   
67   if (vtable (&s4) != vtable (s2))
68     return 1;
69   if (vtable (s2) >= vtable (s3))
70     return 2;
71   if (vtable (s3) >= vtable (s1))
72     return 3;
73   if (vtable (s1) >= vtable (s0))
74     return 4;
77 #else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */
79 int main () 
83 #endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */