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 /* We can use weakref here without dg-require-weak, because we know
128 the symbols are defined, so we don't actually issue the .weak
130 static void S3_s3 () __attribute__((__weakref__ ("_ZN2S32s3Ev")));
131 static void S4_s1 () __attribute__((__weakref__ ("_ZN2S42s1Ev")));
134 // IA-64 uses function descriptors not function pointers in its vtables.
136 #define CMP_VPTR(A, B) (*(void **)(A) == *(void **)(B))
138 #define INC_VPTR(A) ((A) += 2)
139 #define INC_VDATA(A,N) ((A) += (N))
141 #define INC_VPTR(A) ((A) += 4)
142 #define INC_VDATA(A,N) ((A) += 2*(N))
145 #define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B))
146 #define INC_VPTR(A) ((A) += 1)
147 #define INC_VDATA(A,N) ((A) += (N))
156 // Set vtbl to point at the beginning of S4's primary vtable.
157 vptr = (ptrdiff_t **) &s4;
159 INC_VDATA (vtbl, -5);
161 if (*vtbl != ((char*) (S0*) &s4) - (char*) &s4)
164 if (*vtbl != ((char*) (S1*) &s4) - (char*) &s4)
167 if (*vtbl != ((char*) (S2*) &s4) - (char*) &s4)
173 // Skip the RTTI entry.
175 if (! CMP_VPTR (vtbl, &S3_s3))
178 if (! CMP_VPTR (vtbl, &S4_s1))
181 // The S1 vbase offset.
185 // The S4::s1 vcall offset is negative; once you convert to S2, you
186 // have to convert to S4 to find the final overrider.
187 if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4))
196 // Now we're at the S2 offset to top entry.
197 if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4))
200 // Skip the RTTI entry.
202 // Skip the remaining virtual functions -- they are thunks.
207 #else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */
213 #endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */