2 // { dg-require-alias "" }
3 // { dg-options "-fno-strict-aliasing" }
4 // Origin: Mark Mitchell <mark@codesourcery.com>
6 #if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
15 struct S1 : virtual public S0
20 struct S2 : virtual public S1
31 struct S4 : public S3, virtual public S2
60 /* The vtables should look like:
112 S2-in-S4 secondary vtable
125 // These are tricks to allow us to get raw function pointers for
128 void S3_s3 () __attribute__((__alias__ ("_ZN2S32s3Ev")));
129 void S4_s1 () __attribute__((__alias__ ("_ZN2S42s1Ev")));
132 // IA-64 uses function descriptors not function pointers in its vtables.
134 #define CMP_VPTR(A, B) (*(void **)(A) == *(void **)(B))
136 #define INC_VPTR(A) ((A) += 2)
137 #define INC_VDATA(A,N) ((A) += (N))
139 #define INC_VPTR(A) ((A) += 4)
140 #define INC_VDATA(A,N) ((A) += 2*(N))
143 #define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B))
144 #define INC_VPTR(A) ((A) += 1)
145 #define INC_VDATA(A,N) ((A) += (N))
154 // Set vtbl to point at the beginning of S4's primary vtable.
155 vptr = (ptrdiff_t **) &s4;
157 INC_VDATA (vtbl, -5);
159 if (*vtbl != ((char*) (S0*) &s4) - (char*) &s4)
162 if (*vtbl != ((char*) (S1*) &s4) - (char*) &s4)
165 if (*vtbl != ((char*) (S2*) &s4) - (char*) &s4)
171 // Skip the RTTI entry.
173 if (! CMP_VPTR (vtbl, &S3_s3))
176 if (! CMP_VPTR (vtbl, &S4_s1))
179 // The S1 vbase offset.
183 // The S4::s1 vcall offset is negative; once you convert to S2, you
184 // have to convert to S4 to find the final overrider.
185 if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4))
194 // Now we're at the S2 offset to top entry.
195 if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4))
198 // Skip the RTTI entry.
200 // Skip the remaining virtual functions -- they are thunks.
205 #else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */
211 #endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */