2 // { dg-options "-Wno-attribute-alias -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
129 directives. The references to the incompatible virtual S3::s3()
130 and S4::s1() trigger -Wattributes. */
131 static void S3_s3 () __attribute__((__weakref__ ("_ZN2S32s3Ev")));
132 static void S4_s1 () __attribute__((__weakref__ ("_ZN2S42s1Ev")));
135 // IA-64 uses function descriptors not function pointers in its vtables.
137 #define CMP_VPTR(A, B) (*(void **)(A) == *(void **)(B))
139 #define INC_VPTR(A) ((A) += 2)
140 #define INC_VDATA(A,N) ((A) += (N))
142 #define INC_VPTR(A) ((A) += 4)
143 #define INC_VDATA(A,N) ((A) += 2*(N))
146 // HPPA uses function pointers but they point to function descriptors.
150 #define CMP_VPTR(A, B) (*(unsigned long *)(*(A)+16) == *(unsigned long *)((unsigned long)(B)+16))
152 #define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B))
155 extern "C" { unsigned int __canonicalize_funcptr_for_compare (void*); }
156 #define CMP_VPTR(A, B) (__canonicalize_funcptr_for_compare(*(void **)A) == __canonicalize_funcptr_for_compare((void *)B))
157 #endif /* __hpux__ */
159 #define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B))
160 #endif /* __hppa__ */
161 #define INC_VPTR(A) ((A) += 1)
162 #define INC_VDATA(A,N) ((A) += (N))
163 #endif /* __ia64__ */
171 // Set vtbl to point at the beginning of S4's primary vtable.
172 vptr = (ptrdiff_t **) &s4;
174 INC_VDATA (vtbl, -5);
176 if (*vtbl != ((char*) (S0*) &s4) - (char*) &s4)
179 if (*vtbl != ((char*) (S1*) &s4) - (char*) &s4)
182 if (*vtbl != ((char*) (S2*) &s4) - (char*) &s4)
188 // Skip the RTTI entry.
190 if (! CMP_VPTR (vtbl, &S3_s3))
193 if (! CMP_VPTR (vtbl, &S4_s1))
196 // The S1 vbase offset.
200 // The S4::s1 vcall offset is negative; once you convert to S2, you
201 // have to convert to S4 to find the final overrider.
202 if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4))
211 // Now we're at the S2 offset to top entry.
212 if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4))
215 // Skip the RTTI entry.
217 // Skip the remaining virtual functions -- they are thunks.
222 #else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */
228 #endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */