2 // { dg-options "-fno-strict-aliasing" }
3 // Origin: Mark Mitchell <mark@codesourcery.com>
5 #if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
14 struct S1 : virtual public S0
19 struct S2 : virtual public S1
30 struct S4 : public S3, virtual public S2
59 /* The vtables should look like:
111 S2-in-S4 secondary vtable
124 // These are tricks to allow us to get raw function pointers for
127 void S3_s3 () __attribute__((__alias__ ("_ZN2S32s3Ev")));
128 void S4_s1 () __attribute__((__alias__ ("_ZN2S42s1Ev")));
131 // IA-64 uses function descriptors not function pointers in its vtables.
133 #define CMP_VPTR(A, B) (*(void **)(A) == *(void **)(B))
135 #define INC_VPTR(A) ((A) += 2)
136 #define INC_VDATA(A,N) ((A) += (N))
138 #define INC_VPTR(A) ((A) += 4)
139 #define INC_VDATA(A,N) ((A) += 2*(N))
142 #define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B))
143 #define INC_VPTR(A) ((A) += 1)
144 #define INC_VDATA(A,N) ((A) += (N))
153 // Set vtbl to point at the beginning of S4's primary vtable.
154 vptr = (ptrdiff_t **) &s4;
156 INC_VDATA (vtbl, -5);
158 if (*vtbl != ((char*) (S0*) &s4) - (char*) &s4)
161 if (*vtbl != ((char*) (S1*) &s4) - (char*) &s4)
164 if (*vtbl != ((char*) (S2*) &s4) - (char*) &s4)
170 // Skip the RTTI entry.
172 if (! CMP_VPTR (vtbl, &S3_s3))
175 if (! CMP_VPTR (vtbl, &S4_s1))
178 // The S1 vbase offset.
182 // The S4::s1 vcall offset is negative; once you convert to S2, you
183 // have to convert to S4 to find the final overrider.
184 if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4))
193 // Now we're at the S2 offset to top entry.
194 if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4))
197 // Skip the RTTI entry.
199 // Skip the remaining virtual functions -- they are thunks.
204 #else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */
210 #endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */