1 // Origin: Mark Mitchell <mark@codesourcery.com>
2 // Special g++ Options: -fno-strict-aliasing
4 #if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
13 struct S1 : virtual public S0
18 struct S2 : virtual public S1
29 struct S4 : public S3, virtual public S2
58 /* The vtables should look like:
110 S2-in-S4 secondary vtable
123 // These are tricks to allow us to get raw function pointers for
130 // IA-64 uses function descriptors not function pointers in its vtables.
132 #define CMP_VPTR(A, B) (*(void **)(A) == *(void **)(B))
134 #define INC_VPTR(A) ((A) += 2)
135 #define INC_VDATA(A,N) ((A) += (N))
137 #define INC_VPTR(A) ((A) += 4)
138 #define INC_VDATA(A,N) ((A) += 2*(N))
141 #define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B))
142 #define INC_VPTR(A) ((A) += 1)
143 #define INC_VDATA(A,N) ((A) += (N))
152 // Set vtbl to point at the beginning of S4's primary vtable.
153 vptr = (ptrdiff_t **) &s4;
155 INC_VDATA (vtbl, -5);
157 if (*vtbl != ((char*) (S0*) &s4) - (char*) &s4)
160 if (*vtbl != ((char*) (S1*) &s4) - (char*) &s4)
163 if (*vtbl != ((char*) (S2*) &s4) - (char*) &s4)
169 // Skip the RTTI entry.
171 if (! CMP_VPTR (vtbl, &_ZN2S32s3Ev))
174 if (! CMP_VPTR (vtbl, &_ZN2S42s1Ev))
177 // The S1 vbase offset.
181 // The S4::s1 vcall offset is negative; once you convert to S2, you
182 // have to convert to S4 to find the final overrider.
183 if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4))
192 // Now we're at the S2 offset to top entry.
193 if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4))
196 // Skip the RTTI entry.
198 // Skip the remaining virtual functions -- they are thunks.
203 #else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */
209 #endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */