diff options
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.abi/empty.C | 68 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C | 17 |
2 files changed, 79 insertions, 6 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/empty.C b/gcc/testsuite/g++.old-deja/g++.abi/empty.C new file mode 100644 index 00000000000..b7a791f0a94 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/empty.C @@ -0,0 +1,68 @@ +// Special g++ Options: -w +// Origin: Mark Mitchell <mark@codesourcery.com> + +#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 + +struct S0 +{ +}; + +struct S1 : public S0 +{ +}; + +struct S2 : public S1 +{ + char c; +}; + +// In S3, the S1 instance is allocated first at offset zero. The S2 +// instance has to be allocated at a subsequent offset; it's first +// part is also an S1. + +struct S3 : public S1, public S2 +{ +}; + +struct S4 +{ + int i; +}; + +// In S4, in contrast to S3, S2 is allocated first, and S1 can be +// allocated on top of S4. + +struct S5 : public S2, public S1, public S4 +{ +}; + +// The T classes are by-hand layouts that should be equivalent to the +// S classes. + +struct T3 +{ + S1 s1; + S2 s2; +}; + +struct T5 +{ + S2 s2; + S4 s4; +}; + +int main () +{ + if (sizeof (S3) != sizeof (T3)) + return 1; + else if (sizeof (S5) != sizeof (T5)) + return 2; +} + +#else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ + +int main () +{ +} + +#endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ diff --git a/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C b/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C index 8dc3ee46a5c..975d9397ded 100644 --- a/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C +++ b/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C @@ -82,16 +82,16 @@ main () if (xp->adj != delta) return 8; - // For a virtual function, we should see twice the vtable index, - // plus one. `T::h' is in the third slot: there's the RTTI entry, - // then the two virtual functions. + // For a virtual function, we should see the vtable offset, plus + // one. `T::h' is in the second slot: the vtable pointer points to + // the first virtual function. y = &T::h; - if ((ptrdiff_t) yp->ptr != 7) + if ((ptrdiff_t) yp->ptr != sizeof (void *) + 1) return 9; if (yp->adj != 0) return 10; x = (sp) y; - if ((ptrdiff_t) xp->ptr != 7) + if ((ptrdiff_t) xp->ptr != sizeof (void *) + 1) return 11; if (xp->adj != delta) return 12; @@ -103,9 +103,14 @@ main () if (__alignof__ (sdp) != __alignof__ (ptrdiff_t)) return 14; + // The value of a pointer-to-data member should be the offset from + // the start of the structure. sdp z = &S::j; - if ((char *) &s.j - (char *) &s != *((ptrdiff_t *) &z) - 1) + if ((char *) &s.j - (char *) &s != *((ptrdiff_t *) &z)) return 15; + z = 0; + if (*((ptrdiff_t *) &z) != -1) + return 16; } #else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ |