summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.abi
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.old-deja/g++.abi
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.abi')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/aggregates.C126
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/align.C125
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/arraynew.C152
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/bitfields.C160
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/crash1.C21
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C290
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/empty.C69
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/empty2.C136
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/empty3.C24
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/layout1.C52
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/mangle1.C7
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/primary.C73
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/primary2.C22
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/primary3.C45
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/primary4.C28
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/primary5.C37
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/ptrflags.C67
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C146
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vbase1.C115
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vbase2.C28
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vbase3.C27
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vbase4.C166
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vbase5.C22
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vbase6.C22
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vbase7.C41
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vbase8-5.C80
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vbase8-9.C77
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vmihint.C71
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable.C83
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable2.C213
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable3.h179
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable3a.C23
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable3b.C14
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable3c.C14
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable3d.C14
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable3e.C14
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable3f.C15
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable3g.C15
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable3h.C15
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable3i.C14
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vtable3j.C14
41 files changed, 2856 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/aggregates.C b/gcc/testsuite/g++.old-deja/g++.abi/aggregates.C
new file mode 100644
index 000000000..24f430bd6
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/aggregates.C
@@ -0,0 +1,126 @@
+// { dg-do run { target i?86-*-linux* x86_64-*-linux* i?86-*-freebsd* } }
+// { dg-require-effective-target ilp32 }
+// { dg-options "-malign-double" }
+// Origin: Alex Samuel <samuel@codesourcery.com>
+
+/* Test the data layout of C aggregates by checking aggregate size and
+ alignment and field offsets for compliance with the IA-64 ABI. */
+
+template<typename T>
+inline unsigned
+alignmentof ()
+{
+ struct S
+ {
+ char start_;
+ T object_;
+ };
+
+ return (unsigned) & ((S *) 0)->object_;
+}
+
+/* Computes the alignment, in bytes, of TYPE. */
+
+#define alignof(type) (alignmentof<type> ())
+
+/* Computes the offset of FIELD in AGGREGATE. */
+
+#define offsetof(aggregate, field) \
+ ((unsigned) (& ((aggregate*) 0)->field))
+
+
+/* Structs S1, S2, S3, S4, and union U5 are taken from Intel, "IA-64
+ Software Conventions and Runtime Architecture Guide", version of
+ August 1999. */
+
+struct S1
+{
+ char c;
+};
+
+struct S2
+{
+ char c;
+ char d;
+ short s;
+ int n;
+};
+
+struct S3
+{
+ char c;
+ short s;
+};
+
+struct S4
+{
+ char c;
+ double d;
+ short s;
+};
+
+union U5
+{
+ char c;
+ short s;
+ int j;
+};
+
+
+
+int
+main ()
+{
+ if (sizeof (struct S1) != 1)
+ return 1;
+ if (alignof (struct S1) != 1)
+ return 2;
+ if (offsetof (struct S1, c) != 0)
+ return 3;
+
+ if (sizeof (struct S2) != 8)
+ return 4;
+ if (alignof (struct S2) != 4)
+ return 5;
+ if (offsetof (struct S2, c) != 0)
+ return 6;
+ if (offsetof (struct S2, d) != 1)
+ return 7;
+ if (offsetof (struct S2, s) != 2)
+ return 8;
+ if (offsetof (struct S2, n) != 4)
+ return 9;
+
+ if (sizeof (struct S3) != 4)
+ return 10;
+ if (alignof (struct S3) != 2)
+ return 11;
+ if (offsetof (struct S3, c) != 0)
+ return 12;
+ if (offsetof (struct S3, s) != 2)
+ return 13;
+
+ if (sizeof (struct S4) != 24)
+ return 14;
+ if (alignof (struct S4) != 8)
+ return 15;
+ if (offsetof (struct S4, c) != 0)
+ return 16;
+ if (offsetof (struct S4, d) != 8)
+ return 17;
+ if (offsetof (struct S4, s) != 16)
+ return 18;
+
+ if (sizeof (union U5) != 4)
+ return 19;
+ if (alignof (union U5) != 4)
+ return 20;
+ if (offsetof (union U5, c) != 0)
+ return 21;
+ if (offsetof (union U5, s) != 0)
+ return 22;
+ if (offsetof (union U5, j) != 0)
+ return 23;
+
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/align.C b/gcc/testsuite/g++.old-deja/g++.abi/align.C
new file mode 100644
index 000000000..037add32c
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/align.C
@@ -0,0 +1,125 @@
+// { dg-do run { target i?86-*-linux* x86_64-*-linux* i?86-*-freebsd* i?86-*-darwin* } }
+// { dg-require-effective-target ilp32 }
+// { dg-options "-malign-double" }
+// Origin: Alex Samuel <samuel@codesourcery.com>
+
+/* Test the size and alignment of fundamental C types for compliance
+ with the IA-64 ABI. */
+
+template<typename T>
+inline unsigned
+alignmentof ()
+{
+ struct S
+ {
+ char start_;
+ T object_;
+ };
+
+ return (unsigned) & ((S *) 0)->object_;
+}
+
+/* Computes the alignment, in bytes, of TYPE. */
+
+#define alignof(type) (alignmentof<type> ())
+
+enum A { a };
+
+int
+main ()
+{
+ if (sizeof (char) != 1)
+ return 1;
+ if (alignof (char) != 1)
+ return 2;
+ if (sizeof (signed char) != 1)
+ return 3;
+ if (alignof (signed char) != 1)
+ return 4;
+ if (sizeof (unsigned char) != 1)
+ return 5;
+ if (alignof (unsigned char) != 1)
+ return 6;
+ if (sizeof (short) != 2)
+ return 7;
+ if (alignof (short) != 2)
+ return 8;
+ if (sizeof (signed short) != 2)
+ return 9;
+ if (alignof (signed short) != 2)
+ return 10;
+ if (sizeof (unsigned short) != 2)
+ return 11;
+ if (alignof (unsigned short) != 2)
+ return 12;
+ if (sizeof (int) != 4)
+ return 13;
+ if (alignof (int) != 4)
+ return 14;
+ if (sizeof (signed int) != 4)
+ return 15;
+ if (alignof (signed int) != 4)
+ return 16;
+ if (sizeof (unsigned int) != 4)
+ return 17;
+ if (alignof (unsigned int) != 4)
+ return 18;
+ if (sizeof (enum A) != 4)
+ return 19;
+ if (alignof (enum A) != 4)
+ return 20;
+#ifdef HAVE_IA64_TYPES
+ if (sizeof (__int64) != 8)
+ return 21;
+ if (alignof (__int64) != 8)
+ return 22;
+ if (sizeof (signed __int64) != 8)
+ return 23;
+ if (alignof (signed ___int64) != 8)
+ return 24;
+ if (sizeof (unsigned __int64) != 8)
+ return 25;
+ if (alignof (unsigned __int64) != 8)
+ return 26;
+ if (sizeof (__int128) != 16)
+ return 27;
+ if (alignof (__int128) != 16)
+ return 28;
+ if (sizeof (signed __int128) != 16)
+ return 29;
+ if (alignof (signed ___int128) != 16)
+ return 30;
+ if (sizeof (unsigned __int128) != 16)
+ return 31;
+ if (alignof (unsigned ___int128) != 16)
+ return 32;
+#endif /* HAVE_IA64_TYPES */
+ if (sizeof (void *) != 4)
+ return 33;
+ if (alignof (void *) != 4)
+ return 34;
+ if (sizeof (void (*) ()) != 4)
+ return 35;
+ if (alignof (void (*) ()) != 4)
+ return 36;
+ if (sizeof (float) != 4)
+ return 37;
+ if (alignof (float) != 4)
+ return 38;
+ if (sizeof (double) != 8)
+ return 39;
+ if (alignof (double) != 8)
+ return 40;
+#ifdef HAVE_IA64_TYPES
+ if (sizeof (__float80) != 16)
+ return 41;
+ if (alignof (__float80) != 16)
+ return 42;
+ if (sizeof (__float128) != 16)
+ return 43;
+ if (alignof (__float128) != 16)
+ return 44;
+#endif /* HAVE_IA64_TYPES */
+
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/arraynew.C b/gcc/testsuite/g++.old-deja/g++.abi/arraynew.C
new file mode 100644
index 000000000..ff19c7e37
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/arraynew.C
@@ -0,0 +1,152 @@
+// { dg-do run }
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
+
+#include <cstdlib>
+#include <new>
+
+void* p;
+
+void* operator new[](size_t s) throw (std::bad_alloc)
+{
+ // Record the base of the last array allocated.
+ p = malloc (s);
+ return p;
+}
+
+template <typename T>
+void check_no_cookie (int i)
+{
+ void* a = new T[7];
+ if (p != a)
+ exit (i);
+}
+
+template <typename T>
+void check_no_placement_cookie (int i)
+{
+ p = malloc (13 * sizeof (T));
+ void* a = new (p) T[13];
+ if (p != a)
+ exit (i);
+}
+
+template <typename T>
+void check_cookie (int i)
+{
+ void* a = new T[11];
+ size_t x;
+
+ // Compute the cookie location manually.
+#ifdef __ARM_EABI__
+ x = 8;
+#else
+ x = __alignof__ (T);
+ if (x < sizeof (size_t))
+ x = sizeof (size_t);
+#endif
+ if ((char *) a - x != (char *) p)
+ exit (i);
+
+ // Check the cookie value.
+ size_t *sp = ((size_t *) a) - 1;
+ if (*sp != 11)
+ exit (i);
+
+#ifdef __ARM_EABI__
+ sp = ((size_t *) a) - 2;
+ if (*sp != sizeof (T))
+ exit (i);
+#endif
+}
+
+template <typename T>
+void check_placement_cookie (int i)
+{
+ p = malloc (sizeof (T) * 11 + 100);
+ void* a = new (p) T[11];
+ size_t x;
+
+ // Compute the cookie location manually.
+#ifdef __ARM_EABI__
+ x = 8;
+#else
+ x = __alignof__ (T);
+ if (x < sizeof (size_t))
+ x = sizeof (size_t);
+#endif
+ if ((char *) a - x != (char *) p)
+ exit (i);
+
+ // Check the cookie value.
+ size_t *sp = ((size_t *) a) - 1;
+ if (*sp != 11)
+ exit (i);
+
+#ifdef __ARM_EABI__
+ sp = ((size_t *) a) - 2;
+ if (*sp != sizeof (T))
+ exit (i);
+#endif
+}
+
+struct X {};
+
+template <typename T>
+struct Y { int i; virtual void f () {} };
+
+// A class with a non-trivial destructor -- it needs a cookie.
+struct Z { ~Z () {} };
+// Likewise, but this class needs a bigger cookie so that the array
+// elements are correctly aligned.
+struct Z2 { ~Z2 () {} long double d; };
+
+struct W1 { void operator delete[] (void *, size_t) {} };
+struct W2 { void operator delete[] (void *) {}
+ void operator delete[] (void *, size_t) {} };
+struct W3 { void operator delete[] (void *, size_t) {}
+ void operator delete[] (void *) {} };
+struct W4 : public W1 {};
+
+struct V { void *operator new[] (size_t s, void *p)
+ { return p; }
+ ~V () {}
+ };
+
+int main ()
+{
+ // There should be no cookies for types with trivial destructors.
+ check_no_cookie<int> (1);
+ check_no_cookie<X> (2);
+ check_no_cookie<Y<double> > (3);
+
+ // There should be no cookies for allocations using global placement
+ // new.
+ check_no_placement_cookie<int> (4);
+ check_no_placement_cookie<X> (5);
+ check_no_placement_cookie<Z> (6);
+
+ // There should be a cookie when using a non-trivial destructor.
+ check_cookie<Z> (7);
+ check_cookie<Z2> (8);
+
+ // There should be a cookie when using the two-argument array delete
+ // operator.
+ check_cookie<W1> (9);
+ check_cookie<W4> (10);
+ // But not when the one-argument version is also available.
+ check_no_cookie<W2> (11);
+ check_no_cookie<W3> (12);
+
+ // There should be a cookie when using a non-global placement new.
+ check_placement_cookie<V> (13);
+}
+
+#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/bitfields.C b/gcc/testsuite/g++.old-deja/g++.abi/bitfields.C
new file mode 100644
index 000000000..d5c319209
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/bitfields.C
@@ -0,0 +1,160 @@
+// { dg-do run { target i?86-*-linux* x86_64-*-linux* i?86-*-freebsd* } }
+// { dg-require-effective-target ilp32 }
+// { dg-options "-malign-double" }
+// Origin: Alex Samuel <samuel@codesourcery.com>
+
+/* Test the layout of bitfields in C aggretagtes for compliance with
+ the IA-64 ABI. */
+
+#include <cstring>
+
+template<typename T>
+inline unsigned
+alignmentof ()
+{
+ struct S
+ {
+ char start_;
+ T object_;
+ };
+
+ return (unsigned) & ((S *) 0)->object_;
+}
+
+/* Computes the alignment, in bytes, of TYPE. */
+
+#define alignof(type) (alignmentof<type> ())
+
+/* Returns true iff all the bits in the range
+ START_BIT <= bit < START_BIT + NUM_BITS, and only those bits, are
+ set in the region of memory starting at BUF of LENGTH bytes. */
+
+bool
+check_bits (char *buf,
+ unsigned length,
+ unsigned start_bit,
+ unsigned num_bits)
+{
+ for (unsigned bit = 0; bit < 8 * length; ++bit) {
+ bool is_set = (buf[bit / 8] & (1 << (bit % 8))) != 0;
+ if (start_bit <= bit && bit < start_bit + num_bits) {
+ if (! is_set)
+ return false;
+ }
+ else {
+ if (is_set)
+ return false;
+ }
+ }
+ return true;
+}
+
+/* Creates a variable of type AGGREGATE, sets FIELD to -1, and
+ verifies that NUM_BITS bits starting at START_BIT, and no other
+ bits, are set. If the check fails, returns with value RVAL. */
+
+#define CHECK_FIELD(AGGREGATE, FIELD, START_BIT, NUM_BITS, RVAL) \
+ do { \
+ AGGREGATE a__; \
+ std::memset (& a__, 0, sizeof (a__)); \
+ a__.FIELD = -1; \
+ if (! check_bits ((char *) & a__, sizeof (a__), START_BIT, NUM_BITS)) \
+ return RVAL; \
+ } while (0);
+
+
+
+/* Structs S1, S2, S3, S4, and union U5 are taken from Intel, "IA-64
+ Software Conventions and Runtime Architecture Guide", version of
+ August 1999. */
+
+struct S1
+{
+ int j : 5;
+ int k : 6;
+ int m : 7;
+};
+
+#ifdef HAVE_IA64_TYPES
+struct S2
+{
+ short s : 9;
+ __int64 j : 9;
+ char c ;
+ short t : 9;
+ short u : 9;
+ char d ;
+};
+#endif /* HAVE_IA64_TYPES */
+
+struct S3
+{
+ char c ;
+ short s : 8;
+};
+
+union U4
+{
+ char c ;
+ short s : 8;
+};
+
+struct S5
+{
+ char c ;
+ int : 0;
+ char d ;
+ short : 9;
+ char e ;
+ char : 0;
+};
+
+
+int
+main ()
+{
+ if (sizeof (struct S1) != 4)
+ return 1;
+ if (alignof (struct S1) != 4)
+ return 2;
+ CHECK_FIELD (S1, j, 0, 5, 3);
+ CHECK_FIELD (S1, k, 5, 6, 4);
+ CHECK_FIELD (S1, m, 11, 7, 5);
+
+#ifdef HAVE_IA64_TYPES
+ if (sizeof (struct S2) != 16)
+ return 6;
+ if (alignof (struct S2) != 8)
+ return 7;
+ CHECK_FIELD (S2, s, 0, 9, 8);
+ CHECK_FIELD (S2, j, 9, 9, 9);
+ CHECK_FIELD (S2, c, 24, 8, 10);
+ CHECK_FIELD (S2, t, 32, 9, 11);
+ CHECK_FIELD (S2, u, 48, 9, 12);
+ CHECK_FIELD (S2, d, 64, 8, 13);
+#endif /* HAVE_IA64_TYPES */
+
+ if (sizeof (struct S3) != 2)
+ return 14;
+ if (sizeof (struct S3) != 2)
+ return 15;
+ CHECK_FIELD (S3, c, 0, 8, 16);
+ CHECK_FIELD (S3, s, 8, 8, 17);
+
+ if (sizeof (union U4) != 2)
+ return 18;
+ if (alignof (union U4) != 2)
+ return 19;
+ CHECK_FIELD (U4, c, 0, 8, 20);
+ CHECK_FIELD (U4, s, 0, 8, 21);
+
+ if (sizeof (struct S5) != 9)
+ return 22;
+ if (alignof (struct S5) != 1)
+ return 23;
+ CHECK_FIELD (S5, c, 0, 8, 24);
+ CHECK_FIELD (S5, d, 32, 8, 25);
+ CHECK_FIELD (S5, e, 64, 8, 26);
+
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/crash1.C b/gcc/testsuite/g++.old-deja/g++.abi/crash1.C
new file mode 100644
index 000000000..c5f3d5532
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/crash1.C
@@ -0,0 +1,21 @@
+// { dg-do assemble }
+//
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 11 Apr 2001 <nathan@codesourcery.com>
+
+// Bug 1944. We failed to calculate nearly emptiness properly, and
+// lost primary too.
+
+struct A1 {};
+struct A2 {};
+
+struct B1 : virtual A1 {};
+struct B2 : virtual A2 {};
+
+struct C1 : virtual B2 {};
+struct C2 : virtual B2 {};
+
+struct D1 : virtual C1, virtual C2 {};
+struct D2 : virtual C2, virtual B1 {};
+
+struct E : virtual D1, virtual D2 {};
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C b/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C
new file mode 100644
index 000000000..5370fb898
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C
@@ -0,0 +1,290 @@
+// This test fails on VxWorks in kernel mode because it depends on the
+// library version of "::operator new[]" calling the "::operator new"
+// defined in this module. This doesn't work because the library version
+// of "::operator new[]" is built into the kernel itself; library relocations
+// are resolved when the kernel is linked.
+// { dg-do run { xfail { powerpc-ibm-aix* || vxworks_kernel } } }
+// { dg-options "-flat_namespace" { target *-*-darwin[67]* } }
+// Test __cxa_vec routines
+// Copyright (C) 2000, 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 7 Apr 2000 <nathan@nathan@codesourcery.com>
+
+#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
+#include <cxxabi.h>
+#include <stdio.h>
+#include <new>
+#include <stdlib.h>
+#include <setjmp.h>
+
+static int ctor_count = 0;
+static int dtor_count = 0;
+static bool dtor_repeat = false;
+
+// Allocate enough padding to hold an array cookie.
+#ifdef __ARM_EABI__
+#define padding 8
+#else
+#define padding (sizeof (std::size_t))
+#endif
+
+// our pseudo ctors and dtors
+static abi::__cxa_cdtor_return_type ctor (void *x)
+{
+ if (!ctor_count)
+ throw 1;
+ ctor_count--;
+#ifdef __ARM_EABI__
+ return x;
+#endif
+}
+
+static abi::__cxa_cdtor_return_type dtor (void *x)
+{
+ if (!dtor_count)
+ {
+ if (!dtor_repeat)
+ dtor_count--;
+ throw 1;
+ }
+ dtor_count--;
+#ifdef __ARM_EABI__
+ return x;
+#endif
+}
+
+// track new and delete
+static int blocks = 0;
+void *operator new[] (std::size_t size) throw (std::bad_alloc)
+{
+ void *ptr = malloc (size);
+
+ if (!ptr)
+ throw std::bad_alloc ();
+ blocks++;
+ return ptr;
+}
+
+void operator delete[] (void *ptr) throw ()
+{
+ if (ptr)
+ {
+ free (ptr);
+ blocks--;
+ }
+}
+static jmp_buf jump;
+
+// allocate and delete an array with no problems
+void test0 ()
+{
+ static bool started = false;
+
+ if (!started)
+ {
+ started = true;
+ std::set_terminate (test0);
+
+ ctor_count = dtor_count = 5;
+ dtor_repeat = false;
+ blocks = 0;
+
+ try
+ {
+ void *ary = abi::__cxa_vec_new (5, 1, padding, ctor, dtor);
+ abi::__cxa_vec_delete (ary, 1, padding, dtor);
+ if (ctor_count || dtor_count || blocks)
+ longjmp (jump, 1);
+ }
+ catch (...)
+ {
+ longjmp (jump, 2);
+ }
+ }
+ else
+ {
+ longjmp (jump, 3);
+ }
+ return;
+}
+
+// allocate and delete an array with exception on ctor
+void test1 ()
+{
+ static bool started = false;
+
+ if (!started)
+ {
+ started = true;
+ std::set_terminate (test1);
+
+ ctor_count = dtor_count = 5;
+ dtor_repeat = false;
+ blocks = 0;
+
+ ctor_count = 4;
+ try
+ {
+ void *ary = abi::__cxa_vec_new (5, 1, padding, ctor, dtor);
+ longjmp (jump, 1);
+ }
+ catch (...)
+ {
+ // we expect to get here
+ if (ctor_count || dtor_count != 1 || blocks)
+ longjmp (jump, 2);
+ }
+ }
+ else
+ {
+ longjmp (jump, 3);
+ }
+ return;
+}
+
+// allocate and delete an array with exception on dtor
+void test2 ()
+{
+ static bool started = false;
+
+ if (!started)
+ {
+ started = true;
+ std::set_terminate (test2);
+ ctor_count = dtor_count = 5;
+ dtor_repeat = false;
+ blocks = 0;
+
+ dtor_count = 3;
+ try
+ {
+ void *ary = abi::__cxa_vec_new (5, 1, padding, ctor, dtor);
+ abi::__cxa_vec_delete (ary, 1, padding, dtor);
+ longjmp (jump, 1);
+ }
+ catch (...)
+ {
+ // we expect to get here
+ if (ctor_count || dtor_count != -2u || blocks)
+ longjmp (jump, 2);
+ }
+ }
+ else
+ {
+ longjmp (jump, 3);
+ }
+ return;
+}
+
+// allocate an array with double exception on dtor
+void test3 ()
+{
+ static bool started = false;
+
+ if (!started)
+ {
+ started = true;
+ std::set_terminate (test3);
+
+ ctor_count = dtor_count = 5;
+ dtor_repeat = false;
+ blocks = 0;
+
+ dtor_count = 3;
+ dtor_repeat = true;
+ try
+ {
+ void *ary = abi::__cxa_vec_new (5, 1, padding, ctor, dtor);
+ abi::__cxa_vec_delete (ary, 1, padding, dtor);
+ longjmp (jump, 1);
+ }
+ catch (...)
+ {
+ // we do not expect to get here
+ longjmp (jump, 2);
+ }
+ }
+ else
+ {
+ // we expect to get here (via terminate)
+ if (ctor_count || dtor_count || blocks != 1)
+ longjmp (jump, 3);
+ longjmp (jump, -1);
+ }
+ return;
+}
+
+// allocate an array with exception on ctor and exception in cleanup
+void test4 ()
+{
+ static bool started = false;
+
+ if (!started)
+ {
+ started = true;
+ std::set_terminate (test4);
+
+ ctor_count = dtor_count = 5;
+ dtor_repeat = false;
+ blocks = 0;
+
+ ctor_count = 3;
+ dtor_count = 2;
+ try
+ {
+ void *ary = abi::__cxa_vec_new (5, 1, padding, ctor, dtor);
+ longjmp (jump, 1);
+ }
+ catch (...)
+ {
+ // we do not expect to get here
+ longjmp (jump, 2);
+ }
+ }
+ else
+ {
+ // we expect to get here (via terminate)
+ if (ctor_count || dtor_count != -1u || blocks != 1)
+ longjmp (jump, 3);
+ longjmp (jump, -1);
+ }
+ return;
+}
+
+static void (*tests[])() =
+{
+ test0,
+ test1,
+ test2,
+ test3,
+ test4,
+ NULL
+};
+
+int main ()
+{
+ int ix;
+ int n;
+ int errors = 0;
+
+ for (ix = 0; tests[ix]; ix++)
+ {
+ if (n = setjmp (jump))
+ {
+ if (n > 0)
+ {
+ printf ("test %d failed %d\n", ix, n);
+ errors++;
+ }
+ }
+ else
+ tests[ix] ();
+ }
+ return errors;
+}
+
+#else
+int main ()
+{
+ return 0;
+}
+#endif
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 000000000..40aac9e9d
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/empty.C
@@ -0,0 +1,69 @@
+// { dg-do run }
+// { dg-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/empty2.C b/gcc/testsuite/g++.old-deja/g++.abi/empty2.C
new file mode 100644
index 000000000..65d6a4594
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/empty2.C
@@ -0,0 +1,136 @@
+// { dg-do assemble }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 12 Apr 2001 <nathan@codesourcery.com>
+
+// Check we deal with trailing empty base classes properly
+
+struct A {};
+struct B1 : A {};
+struct B2 : A {};
+struct B3 : A {};
+struct B4 : A {};
+struct B5 : A {};
+struct B6 : A {};
+struct B7 : A {};
+struct B8 : A {};
+
+struct C1 : B1
+{
+ virtual void Foo () {}
+};
+struct C2 : B1, B2
+{
+ virtual void Foo () {}
+};
+struct C3 : B1, B2, B3
+{
+ virtual void Foo () {}
+};
+struct C4 : B1, B2, B3, B4
+{
+ virtual void Foo () {}
+};
+struct C5 : B1, B2, B3, B4, B5
+{
+ virtual void Foo () {}
+};
+struct C6 : B1, B2, B3, B4, B5, B6
+{
+ virtual void Foo () {}
+};
+struct C7 : B1, B2, B3, B4, B5, B6, B7
+{
+ virtual void Foo () {}
+};
+struct C8 : B1, B2, B3, B4, B5, B6, B7, B8
+{
+ virtual void Foo () {}
+};
+
+struct D1 : virtual C1 {};
+struct D2 : virtual C2 {};
+struct D3 : virtual C3 {};
+struct D4 : virtual C4 {};
+struct D5 : virtual C5 {};
+struct D6 : virtual C6 {};
+struct D7 : virtual C7 {};
+struct D8 : virtual C8 {};
+
+unsigned const nearly_empty_size = sizeof (D1);
+
+template <typename Cn, typename Dn> int Check (Dn const &ref)
+{
+ if ((sizeof (Cn) <= nearly_empty_size)
+ != (static_cast <void const *> (&ref)
+ == static_cast <Cn const *> (&ref)))
+ return 1;
+ return 0;
+}
+
+template <typename Bn, typename Cn> int Check ()
+{
+ Cn c[2];
+
+ if (static_cast <A *> (static_cast <B1 *> (&c[1]))
+ == static_cast <A *> (static_cast <Bn *> (&c[0])))
+ return 1;
+ return 0;
+}
+
+
+int main ()
+{
+#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
+ if (Check<B1, C1> ())
+ return 1;
+ if (Check<B2, C2> ())
+ return 2;
+ if (Check<B3, C3> ())
+ return 3;
+ if (Check<B4, C4> ())
+ return 4;
+ if (Check<B5, C5> ())
+ return 5;
+ if (Check<B6, C6> ())
+ return 6;
+ if (Check<B7, C7> ())
+ return 7;
+ if (Check<B8, C8> ())
+ return 8;
+
+ if (Check<C1> (D1 ()))
+ return 11;
+ if (Check<C2> (D2 ()))
+ return 12;
+ if (Check<C3> (D3 ()))
+ return 13;
+ if (Check<C4> (D4 ()))
+ return 14;
+ if (Check<C5> (D5 ()))
+ return 15;
+ if (Check<C6> (D6 ()))
+ return 16;
+ if (Check<C7> (D7 ()))
+ return 17;
+ if (Check<C8> (D8 ()))
+ return 18;
+
+ if (sizeof (C2) == nearly_empty_size)
+ return 22;
+ if (sizeof (C3) == nearly_empty_size)
+ return 23;
+ if (sizeof (C4) == nearly_empty_size)
+ return 24;
+ if (sizeof (C5) == nearly_empty_size)
+ return 25;
+ if (sizeof (C6) == nearly_empty_size)
+ return 26;
+ if (sizeof (C7) == nearly_empty_size)
+ return 27;
+ if (sizeof (C8) == nearly_empty_size)
+ return 28;
+#endif
+ return 0;
+
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/empty3.C b/gcc/testsuite/g++.old-deja/g++.abi/empty3.C
new file mode 100644
index 000000000..071431c5c
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/empty3.C
@@ -0,0 +1,24 @@
+// { dg-do assemble }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 12 Apr 2001 <nathan@codesourcery.com>
+
+// Check we deal with aligning virtual bases after a trailing empty
+// base class properly
+
+struct A {};
+struct B1 : A {};
+struct B2 : A {};
+struct B3 : A {};
+
+struct C : B1, B2, virtual B3 {};
+
+int main ()
+{
+#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
+ C c;
+ if (((char *)static_cast <B3 *> (&c) - (char *)&c) % __alignof__ (C))
+ return 1;
+#endif
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/layout1.C b/gcc/testsuite/g++.old-deja/g++.abi/layout1.C
new file mode 100644
index 000000000..23fd891c8
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/layout1.C
@@ -0,0 +1,52 @@
+// { dg-do run }
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
+
+struct R
+{
+ virtual void r ();
+};
+
+struct S
+{
+ virtual void f ();
+};
+
+struct T : virtual public S
+{
+ virtual void g ();
+};
+
+struct U : public R, virtual public T
+{
+ virtual void h ();
+};
+
+struct V : public R, virtual public S, virtual public T
+{
+ virtual void v ();
+};
+
+struct U1
+{
+ R r;
+ T t;
+};
+
+int main ()
+{
+ if (sizeof (U) != sizeof (U1))
+ return 1;
+ if (sizeof (V) != sizeof (U1))
+ 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/mangle1.C b/gcc/testsuite/g++.old-deja/g++.abi/mangle1.C
new file mode 100644
index 000000000..d738f31b9
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/mangle1.C
@@ -0,0 +1,7 @@
+// { dg-do assemble }
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+struct S {};
+
+void f (void (S::*)()) {}
+void f (void (S::*)() const) {}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/primary.C b/gcc/testsuite/g++.old-deja/g++.abi/primary.C
new file mode 100644
index 000000000..692ef3328
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/primary.C
@@ -0,0 +1,73 @@
+// { dg-do run }
+// Test to see that primary bases are selected correctly.
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
+
+// S1 is a nearly-empty base.
+
+struct S1
+{
+ virtual void f ()
+ {
+ }
+};
+
+// S2 is a dynamic, but not nearly-empty, base.
+
+struct S2
+{
+ virtual void g ()
+ {
+ }
+
+ int i;
+};
+
+// S1 should be the primary base.
+
+struct T1 : public S1, public S2
+{
+};
+
+// S2 should be the primary base.
+
+struct T2 : public S2, public S1
+{
+};
+
+// S2 should be the primary base.
+
+struct T3 : virtual public S1, public S2
+{
+};
+
+// S1 should be the primary base.
+
+struct T4 : virtual public S1, virtual public S2
+{
+};
+
+// Check that Y is the primary base for X. Otherwise, return N.
+#define CHECK_PRIMARY_BASE(X, Y, N) \
+ { \
+ X x; \
+ if ((void*) &x != (void *) (Y*) (&x)) \
+ return N; \
+ }
+
+int main ()
+{
+ CHECK_PRIMARY_BASE (T1, S1, 1);
+ CHECK_PRIMARY_BASE (T2, S2, 2);
+ CHECK_PRIMARY_BASE (T3, S2, 3);
+ CHECK_PRIMARY_BASE (T4, S1, 4);
+}
+
+#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/primary2.C b/gcc/testsuite/g++.old-deja/g++.abi/primary2.C
new file mode 100644
index 000000000..fd440c0b0
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/primary2.C
@@ -0,0 +1,22 @@
+// { dg-do run }
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check primary bases are chosen correctly.
+
+struct A {virtual void Foo () {}};
+struct B : virtual A {};
+struct C : virtual B {};
+struct D : virtual B, virtual C {};
+
+int main ()
+{
+ D d;
+
+#if __GXX_ABI_VERSION >= 100
+ if (sizeof (D) != sizeof (A))
+ return 1;
+#endif
+
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/primary3.C b/gcc/testsuite/g++.old-deja/g++.abi/primary3.C
new file mode 100644
index 000000000..3ebc3ec0d
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/primary3.C
@@ -0,0 +1,45 @@
+// { dg-do run }
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check primary bases are chosen correctly.
+
+struct A {virtual void Foo () {}};
+struct B1 : virtual A {};
+struct B2 : virtual A {};
+struct C : virtual B1, B2 {};
+struct D : virtual C {};
+
+int main ()
+{
+ C c;
+ D d;
+
+ A *apc = &c;
+ B1 *b1pc = &c;
+ B2 *b2pc = &c;
+
+ A *apd = &d;
+ B1 *b1pd = &d;
+ B2 *b2pd = &d;
+ C *cpd = &d;
+
+#if __GXX_ABI_VERSION >= 100
+ if (static_cast <void *> (apc) != static_cast <void *> (b1pc))
+ return 1;
+ if (static_cast <void *> (&c) != static_cast <void *> (b2pc))
+ return 2;
+ if (static_cast <void *> (b1pc) == static_cast <void *> (b2pc))
+ return 3;
+
+ if (static_cast <void *> (apd) != static_cast <void *> (b1pd))
+ return 11;
+ if (static_cast <void *> (b2pd) != static_cast <void *> (&d))
+ return 12;
+ if (static_cast <void *> (b2pd) != static_cast <void *> (cpd))
+ return 13;
+ if (static_cast <void *> (b1pd) == static_cast <void *> (b2pd))
+ return 14;
+#endif
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/primary4.C b/gcc/testsuite/g++.old-deja/g++.abi/primary4.C
new file mode 100644
index 000000000..3e36c58a3
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/primary4.C
@@ -0,0 +1,28 @@
+// { dg-do run }
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check primary bases are chosen correctly.
+
+struct A { virtual void Foo () {}};
+
+struct B1 : virtual A {};
+struct B2 : virtual A {};
+
+struct C : virtual B1 {};
+
+struct D : virtual B1, B2, C {};
+
+int main ()
+{
+ D d;
+ A *ap = &d;
+ C *cp = &d;
+
+#if __GXX_ABI_VERSION >= 100
+ if (static_cast <void *> (ap) != static_cast <void *> (cp))
+ return 1;
+#endif
+
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/primary5.C b/gcc/testsuite/g++.old-deja/g++.abi/primary5.C
new file mode 100644
index 000000000..07ea2d7d8
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/primary5.C
@@ -0,0 +1,37 @@
+// { dg-do run }
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check primary bases are chosen correctly.
+
+struct A1
+{
+ virtual void Foo () {}
+};
+
+struct A : A1
+{
+};
+
+struct B : A
+{
+};
+
+struct C : virtual B
+{
+};
+
+struct D : virtual B, virtual C
+{
+};
+
+int main()
+{
+ D d;
+#if __GXX_ABI_VERSION >= 100
+ if (sizeof (D) != sizeof (A))
+ return 1;
+#endif
+
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/ptrflags.C b/gcc/testsuite/g++.old-deja/g++.abi/ptrflags.C
new file mode 100644
index 000000000..d4bdc212e
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/ptrflags.C
@@ -0,0 +1,67 @@
+// { dg-do run }
+// Test rtti pointer flags
+// Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 15 Apr 2000 <nathan@nathan@codesourcery.com>
+
+#include <typeinfo>
+
+#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
+#include <cxxabi.h>
+
+struct A {int m;};
+struct B;
+
+using namespace abi;
+
+int expect (int flags, std::type_info const &info)
+{
+ abi::__pbase_type_info const *ptr =
+ dynamic_cast <abi::__pbase_type_info const *> (&info);
+ if (!ptr)
+ return 0;
+ if (ptr->__flags != flags)
+ return 0;
+ return 1;
+}
+
+int main ()
+{
+ if (! expect (0, typeid (A *)))
+ return 1;
+ if (! expect (1, typeid (A const *)))
+ return 2;
+ if (! expect (2, typeid (A volatile *)))
+ return 3;
+ if (! expect (4, typeid (A *__restrict__ *)))
+ return 4;
+ if (! expect (0, typeid (int A::*)))
+ return 5;
+ if (! expect (0, typeid (int A::**)))
+ return 6;
+
+ if (! expect (8 | 0, typeid (B *)))
+ return 11;
+ if (! expect (8 | 1, typeid (B const *)))
+ return 12;
+ if (! expect (8 | 2, typeid (B volatile *)))
+ return 13;
+ if (! expect (8 | 4, typeid (B *__restrict__ *)))
+ return 14;
+ if (! expect (16 | 0, typeid (int B::*)))
+ return 15;
+ if (! expect (8 | 0, typeid (int B::**)))
+ return 16;
+ if (! expect (8 | 0, typeid (B A::*)))
+ return 17;
+ if (! expect (24, typeid (B B::*)))
+ return 18;
+
+ return 0;
+}
+
+#else
+int main ()
+{
+ return 0;
+}
+#endif
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C b/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C
new file mode 100644
index 000000000..077fa5084
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C
@@ -0,0 +1,146 @@
+// { dg-do run }
+// { dg-options "-fno-strict-aliasing" }
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+/* Generally, the lowest bit of the ptr is used to indicate whether a
+ ptr-to-mem-func points to a virtual or a non-virtual member
+ function. However, some platforms use all bits to encode a
+ function pointer. Such platforms use the lowest bit of the delta,
+ that is shifted left by one bit. */
+#if defined __MN10300__ || defined __SH5__ || defined __arm__ || defined __thumb__ || defined __mips__
+#define ADJUST_PTRFN(func, virt) ((void (*)())(func))
+#define ADJUST_DELTA(delta, virt) (((delta) << 1) + !!(virt))
+#else
+#define ADJUST_PTRFN(func, virt) ((void (*)())((ptrdiff_t)(func) + !!(virt)))
+#define ADJUST_DELTA(delta, virt) (delta)
+#endif
+
+/* IA64 uses function descriptors instead of function pointers in its
+ vtables, which means that we can't meaningfully compare them directly. */
+#if defined __ia64__
+#define CMP_PTRFN(A, B) (*(void **)(A) == *(void **)(B))
+#define VPTE_SIZE (16)
+#else
+#define CMP_PTRFN(A, B) ((A) == (B))
+#define VPTE_SIZE sizeof(void *)
+#endif
+
+#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
+
+// Check that pointers-to-member functions are represented correctly.
+
+#include <cstddef>
+
+struct S
+{
+ int i;
+ int j;
+};
+
+// Because S does not have a VPTR, it will not be a primary base of T,
+// and will therefore end up at a nonzero offset.
+
+struct T : public S
+{
+ void f () {}
+ virtual void g () {}
+ virtual void h () {}
+};
+
+// Provide access to the raw function pointers. This is
+// mangling-dependent.
+
+extern "C" void _ZN1T1fEv ();
+extern "C" void _ZN1T1gEv ();
+extern "C" void _ZN1T1hEv ();
+
+// This structure is a C representation of a pointer-to-member.
+
+struct ptrmemfunc
+{
+ void (*ptr) ();
+ ptrdiff_t adj;
+};
+
+typedef int S::*sdp;
+typedef void (S::*sp)();
+typedef void (T::*tp)();
+
+int
+main ()
+{
+ S s;
+ T t;
+ sp x;
+ tp y;
+ ptrmemfunc *xp = (ptrmemfunc *) &x;
+ ptrmemfunc *yp = (ptrmemfunc *) &y;
+ ptrdiff_t delta = ((char *) &t) - ((char*) (S*) (&t));
+
+ // Pointers-to-function-members should have the same size and
+ // alignment as the PTRMEMFUNC type.
+ if (sizeof (sp) != sizeof (ptrmemfunc))
+ return 1;
+ if (__alignof__ (sp) != __alignof__ (ptrmemfunc))
+ return 2;
+
+ // The NULL pointer-to-member should have a NULL first PTR field.
+ x = 0;
+ if (xp->ptr != 0)
+ return 3;
+ y = x;
+ if (yp->ptr != 0)
+ return 4;
+
+ // A non-virtual function should have a pointer to the function.
+ // There should be no adjustment for the `T' version, and an
+ // appropriate adjustment for the `S' version.
+ y = &T::f;
+ if (! CMP_PTRFN (yp->ptr, ADJUST_PTRFN (&_ZN1T1fEv, 0)))
+ return 5;
+ if (yp->adj != ADJUST_DELTA (0, 0))
+ return 6;
+ x = (sp) y;
+ if (! CMP_PTRFN (xp->ptr, ADJUST_PTRFN (&_ZN1T1fEv, 0)))
+ return 7;
+ if (xp->adj != ADJUST_DELTA (delta, 0))
+ return 8;
+
+ // 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 (yp->ptr != ADJUST_PTRFN (VPTE_SIZE, 1))
+ return 9;
+ if (yp->adj != ADJUST_DELTA (0, 1))
+ return 10;
+ x = (sp) y;
+ if (xp->ptr != ADJUST_PTRFN (VPTE_SIZE, 1))
+ return 11;
+ if (xp->adj != ADJUST_DELTA (delta, 1))
+ return 12;
+
+ // Pointers-to-data-members should have the same size and alignment
+ // as a ptrdiff_t.
+ if (sizeof (sdp) != sizeof (ptrdiff_t))
+ return 13;
+ 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))
+ return 15;
+ z = 0;
+ if (*((ptrdiff_t *) &z) != -1)
+ return 16;
+}
+
+#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/vbase1.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase1.C
new file mode 100644
index 000000000..680bec737
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase1.C
@@ -0,0 +1,115 @@
+// { dg-do run }
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 16 Jan 2001 <nathan@codesourcery.com>
+
+// Bug 1611. Under the new ABI, the vtable can be clobbered during dtoring our
+// primary vbase. We mustn't use the vtable after that to locate our vbases.
+
+#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
+#include <stdio.h>
+#include <stdlib.h>
+
+int *ctorVBase = 0;
+int *dtorVBase = 0;
+int *ctorVDerived = 0;
+int *dtorVDerived = 0;
+int *ctorB = 0;
+int *dtorB = 0;
+
+struct VBase
+{
+ int member;
+ VBase ()
+ {
+ if (ctorVBase) exit (1);
+ ctorVBase = &member;
+ }
+ virtual ~VBase ()
+ {
+ if (dtorVBase) exit (2);
+ dtorVBase = &member;
+ if (dtorVBase != ctorVBase) exit (3);
+ }
+ void Offset () const
+ {
+ printf ("VBase\n");
+ printf (" VBase::member %d\n", &this->VBase::member - (int *)this);
+ }
+};
+
+struct VDerived : virtual VBase
+{
+ int member;
+
+ VDerived ()
+ {
+ if (ctorVDerived) exit (4);
+ ctorVDerived = &member;
+ }
+ virtual ~VDerived ()
+ {
+ if (dtorVDerived) exit (5);
+ dtorVDerived = &member;
+ if (dtorVDerived != ctorVDerived) exit (6);
+ }
+ void Offset () const
+ {
+ printf ("VDerived\n");
+ printf (" VBase::member %d\n", &this->VBase::member - (int *)this);
+ printf (" VDerived::member %d\n", &this->VDerived::member - (int *)this);
+ }
+};
+struct B : virtual VBase
+{
+ int member;
+ void Offset () const
+ {
+ printf ("B\n");
+ printf (" VBase::member %d\n", &this->VBase::member - (int *)this);
+ printf (" B::member %d\n", &this->B::member - (int *)this);
+ }
+};
+struct MostDerived : B, virtual VDerived
+{
+ int member;
+ void Offset () const
+ {
+ printf ("MostDerived\n");
+ printf (" VBase::member %d\n", &this->VBase::member - (int *)this);
+ printf (" B::member %d\n", &this->B::member - (int *)this);
+ printf (" VDerived::member %d\n", &this->VDerived::member - (int *)this);
+ printf (" MostDerived::member %d\n", &this->MostDerived::member - (int *)this);
+ }
+};
+
+
+int main ()
+{
+ {
+ MostDerived dum;
+
+ int *this_ = (int *)&dum;
+
+ if (ctorVBase != &dum.VBase::member)
+ return 23;
+ if (ctorVDerived != &dum.VDerived::member)
+ return 24;
+
+ printf (" VBase::member %d\n", &dum.VBase::member - this_);
+ printf (" B::member %d\n", &dum.B::member - this_);
+ printf (" VDerived::member %d\n", &dum.VDerived::member - this_);
+ printf (" MostDerived::member %d\n", &dum.MostDerived::member - this_);
+ dum.MostDerived::Offset ();
+ dum.B::Offset ();
+ dum.VDerived::Offset ();
+ dum.VBase::Offset ();
+ }
+ return 0;
+}
+#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/vbase2.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase2.C
new file mode 100644
index 000000000..8c2cdfb4a
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase2.C
@@ -0,0 +1,28 @@
+// { dg-do run }
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 5 Jun 2001 <nathan@codesourcery.com>
+
+// Bug 3006. Constructor vtables were wrong.
+
+struct A
+{
+ virtual ~A() {}
+};
+
+class B : public virtual A {};
+class C : public virtual B {};
+class D1 : public virtual C {};
+class D2 : public virtual C {};
+class E
+ : public virtual D1,
+ public virtual D2
+{
+};
+
+
+int
+main(int argc, char* argv[])
+{
+ new E;
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase3.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase3.C
new file mode 100644
index 000000000..11d49d4a1
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase3.C
@@ -0,0 +1,27 @@
+// { dg-do run }
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 5 Jun 2001 <nathan@codesourcery.com>
+
+// Bug 3061. Constructor vtables were wrong.
+
+class A_base {
+ public:
+ virtual void foo() { }
+};
+class A_skel : virtual public A_base { };
+
+class B_base : virtual public A_base { };
+class B_skel : virtual public B_base, virtual public A_skel { };
+
+class C_base : virtual public B_base { };
+class C_skel : virtual public C_base, virtual public B_skel { };
+
+class D_base : virtual public C_base { };
+class D_skel : virtual public D_base, virtual public C_skel { };
+
+class D_impl : virtual public D_skel { };
+
+int main()
+{
+ D_impl i;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase4.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase4.C
new file mode 100644
index 000000000..8b083947e
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase4.C
@@ -0,0 +1,166 @@
+// { dg-do run }
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 9 Jun 2001 <nathan@codesourcery.com>
+
+// Bug 3089. We ICE'd in construction vtables.
+
+int failed;
+
+void fail (int val)
+{
+ if (!failed)
+ failed = val;
+}
+
+struct A
+{
+ virtual ~A();
+ A ();
+ virtual void check (void *whole, void *base);
+};
+
+A::A ()
+{
+ check (this, this);
+}
+A::~A ()
+{
+ check (this, this);
+}
+
+void A::check (void *whole, void *base)
+{
+ if (dynamic_cast <void *> (this) != whole)
+ fail (1);
+ else if (this != base)
+ fail (2);
+}
+
+struct B
+{
+ virtual ~B ();
+ B ();
+ virtual void check (void *whole, void *base);
+};
+
+B::B ()
+{
+ check (this, this);
+}
+B::~B ()
+{
+ check (this, this);
+}
+void B::check (void *whole, void *base)
+{
+ if (dynamic_cast <void *> (this) != whole)
+ fail (3);
+ else if (this != base)
+ fail (4);
+}
+
+struct C : virtual public B, virtual public A
+{
+ virtual ~C ();
+ C ();
+ virtual void check (void *whole, void *base);
+};
+C::C ()
+{
+ check (this, this);
+}
+C::~C ()
+{
+ check (this, this);
+}
+void C::check (void *whole, void *base)
+{
+ if (dynamic_cast <void *> (this) != whole)
+ fail (5);
+ else if (this != base)
+ fail (6);
+ A::check (whole, static_cast <A *> (this));
+ B::check (whole, static_cast <B *> (this));
+}
+
+struct D : virtual public A
+{
+ virtual ~D ();
+ D ();
+ virtual void check (void *whole, void *base);
+};
+D::D ()
+{
+ check (this, this);
+}
+D::~D ()
+{
+ check (this, this);
+}
+void D::check (void *whole, void *base)
+{
+ if (dynamic_cast <void *> (this) != whole)
+ fail (5);
+ else if (this != base)
+ fail (6);
+ A::check (whole, static_cast <A *> (this));
+}
+
+struct E : virtual public C, virtual public D
+{
+ virtual ~E ();
+ E ();
+ virtual void check (void *whole, void *base);
+};
+E::E ()
+{
+ check (this, this);
+}
+E::~E ()
+{
+ check (this, this);
+}
+void E::check (void *whole, void *base)
+{
+ if (dynamic_cast <void *> (this) != whole)
+ fail (5);
+ else if (this != base)
+ fail (6);
+ C::check (whole, static_cast <C *> (this));
+ D::check (whole, static_cast <D *> (this));
+}
+
+struct F : virtual public E
+{
+ virtual ~F ();
+ F ();
+ virtual void check (void *whole, void *base);
+};
+F::F ()
+{
+ check (this, this);
+}
+F::~F ()
+{
+ check (this, this);
+}
+void F::check (void *whole, void *base)
+{
+ if (dynamic_cast <void *> (this) != whole)
+ fail (5);
+ else if (this != base)
+ fail (6);
+ E::check (whole, static_cast <F *> (this));
+}
+
+int main ()
+{
+ A a;
+ B b;
+ C c;
+ D d;
+ E e;
+ F f;
+
+ return failed;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase5.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase5.C
new file mode 100644
index 000000000..4e1b4efbd
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase5.C
@@ -0,0 +1,22 @@
+// { dg-do assemble }
+//
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 12 Jun 2001 <nathan@codesourcery.com>
+
+// 3130. A virtual base can have canonical and non-canonical instances
+// of its primary. The canonical one should be first in dfs order.
+
+struct A
+{
+ virtual ~A ();
+};
+
+struct B
+{
+ virtual ~B ();
+};
+
+
+struct C : virtual public A, virtual public B {};
+class D : public virtual C {};
+class E : public virtual C, public virtual D {};
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase6.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase6.C
new file mode 100644
index 000000000..69764936d
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase6.C
@@ -0,0 +1,22 @@
+// { dg-do assemble }
+//
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 12 Jun 2001 <nathan@codesourcery.com>
+
+// 3131.
+
+struct A
+{
+ virtual ~A ();
+};
+
+struct B
+{
+ virtual ~B ();
+};
+
+
+struct C : virtual public B {};
+struct D : virtual public A, virtual public C {};
+struct E : public virtual C {};
+struct F : public virtual D, public virtual E {};
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase7.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase7.C
new file mode 100644
index 000000000..a9d5e50a4
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase7.C
@@ -0,0 +1,41 @@
+// { dg-do run }
+// Build don't run
+//
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 12 Jun 2001 <nathan@codesourcery.com>
+
+// 3132. A virtual thunk was missing.
+
+struct A
+{
+ int x;
+ virtual ~A() {}
+};
+
+struct B
+{
+ virtual ~B() { }
+};
+
+
+struct C
+{
+ virtual ~C () {}
+};
+
+
+struct D : public virtual A {};
+struct E : virtual public B, virtual public D {};
+struct F : virtual public C, virtual public E {};
+struct G : public virtual E {};
+
+struct H : public virtual F, public virtual G
+{
+ virtual ~H ();
+};
+H::~H() {}
+
+int main ()
+{
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase8-5.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-5.C
new file mode 100644
index 000000000..704f91a7a
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-5.C
@@ -0,0 +1,80 @@
+// { dg-do run }
+// { dg-options "-w" }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 24 Jul 2001 <nathan@codesourcery.com>
+
+// Origin stefan@space.twc.de
+// Bug 3145 case 5. Horribly complicated class hierarchy
+
+class C0
+{};
+class C1
+ : virtual public C0
+{};
+class C2
+ : public C0
+ , virtual public C1
+{};
+class C3
+ : virtual public C0
+ , virtual public C2
+ , public C1
+{};
+class C4
+ : virtual public C0
+ , virtual public C2
+ , virtual public C1
+ , virtual public C3
+{};
+class C5
+ : virtual public C3
+ , virtual public C2
+ , virtual public C0
+ , public C4
+ , virtual public C1
+{};
+class C6
+ : public C0
+ , virtual public C3
+ , public C4
+ , virtual public C5
+ , public C1
+{};
+class C7
+ : virtual public C3
+ , public C5
+ , public C2
+ , virtual public C4
+ , public C6
+ , public C0
+{};
+class C8
+ : virtual public C2
+ , public C5
+ , public C7
+ , public C1
+ , public C0
+ , public C4
+ , public C3
+{};
+class C9
+ : public C3
+ , public C2
+ , virtual public C6
+ , public C8
+ , virtual public C7
+ , public C5
+{};
+main() {
+ C0 c0;
+ C1 c1;
+ C2 c2;
+ C3 c3;
+ C4 c4;
+ C5 c5;
+ C6 c6;
+ C7 c7;
+ C8 c8;
+ C9 c9;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase8-9.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-9.C
new file mode 100644
index 000000000..bc922e85c
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-9.C
@@ -0,0 +1,77 @@
+// { dg-do run }
+// { dg-options "-ansi -pedantic-errors -w" }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 14 Jun 2001 <nathan@codesourcery.com>
+
+// Bug 3145, generated by script provided by stefan@space.twc.de
+// This is case number 9
+
+class C0
+{};
+class C1
+ : public C0
+{};
+class C2
+ : public C1
+ , public C0
+{};
+class C3
+ : virtual public C0
+ , public C2
+ , virtual public C1
+{};
+class C4
+ : virtual public C2
+ , public C0
+ , virtual public C3
+ , public C1
+{};
+class C5
+ : public C0
+ , public C1
+ , public C4
+ , virtual public C2
+ , public C3
+{};
+class C6
+ : public C1
+ , public C3
+ , virtual public C5
+ , virtual public C2
+ , public C0
+ , virtual public C4
+{};
+class C7
+ : virtual public C1
+ , virtual public C0
+ , public C6
+ , virtual public C2
+ , public C5
+{};
+class C8
+ : virtual public C1
+ , virtual public C4
+ , public C0
+ , virtual public C7
+ , virtual public C2
+{};
+class C9
+ : virtual public C1
+ , virtual public C6
+ , public C8
+ , virtual public C2
+ , public C0
+{};
+int main() {
+ C0 c0;
+ C1 c1;
+ C2 c2;
+ C3 c3;
+ C4 c4;
+ C5 c5;
+ C6 c6;
+ C7 c7;
+ C8 c8;
+ C9 c9;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vmihint.C b/gcc/testsuite/g++.old-deja/g++.abi/vmihint.C
new file mode 100644
index 000000000..fd9f3766f
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vmihint.C
@@ -0,0 +1,71 @@
+// { dg-do run }
+// Test rtti hint flags
+// Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 3 Apr 2000 <nathan@nathan@codesourcery.com>
+
+#include <typeinfo>
+
+#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
+#include <cxxabi.h>
+
+struct A {int m;};
+struct A1vA : virtual A {int m;};
+struct A2vA : virtual A {int m;};
+struct A1A : A {int m;};
+struct A2A : A {int m;};
+struct B {int m;};
+
+struct C1 : B, virtual A {int m;};
+
+struct D1 : A1vA, A2vA {int m;};
+
+struct E1 : A1A, A2A {int m;};
+
+struct E2 : A1A, A2vA {int m;};
+
+struct F1 : A1A, A1vA, A2vA {int m;};
+
+struct P1 : protected A {int m;};
+
+struct P2 : B, P1 {int m;};
+
+using namespace abi;
+
+int expect (int flags, std::type_info const &info)
+{
+ abi::__vmi_class_type_info const *ptr =
+ dynamic_cast <abi::__vmi_class_type_info const *> (&info);
+ if (!ptr)
+ return 0;
+ if (ptr->__flags != flags)
+ return 0;
+ return 1;
+}
+
+int main ()
+{
+ if (! expect (0, typeid (C1)))
+ return 1;
+ if (! expect (2, typeid (D1)))
+ return 2;
+ if (! expect (1, typeid (E1)))
+ return 3;
+ if (! expect (1, typeid (E2)))
+ return 4;
+ if (! expect (3, typeid (F1)))
+ return 5;
+
+ if (!expect (0, typeid (P1)))
+ return 6;
+ if (!expect (0, typeid (P2)))
+ return 7;
+
+ return 0;
+}
+
+#else
+int main ()
+{
+ return 0;
+}
+#endif
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable.C
new file mode 100644
index 000000000..b93710af7
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable.C
@@ -0,0 +1,83 @@
+// { dg-do run }
+// { dg-options "-fno-strict-aliasing" }
+// Test various aspects of vtable layout.
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
+
+struct S0
+{
+ virtual void h ()
+ {
+ }
+
+ int k;
+};
+
+
+struct S1
+{
+ virtual void f ()
+ {
+ }
+
+ int i;
+};
+
+struct S2 : virtual public S0
+{
+ virtual void g ()
+ {
+ }
+
+ int j;
+};
+
+struct S3
+{
+ virtual void k ()
+ {
+ }
+
+ int l;
+};
+
+struct S4 : public virtual S1, public S2, public S3
+{
+};
+
+inline void* vtable (void *object)
+{
+ // The vptr is always the first part of the object.
+ return * (void **) object;
+}
+
+int main ()
+{
+ // The vtable layout order for S4 should consist of S4's primary
+ // vtable (shared with S2), followed by the vtable for S3 (because
+ // it is a non-virtual base). Then, these should be followed by the
+ // the vtables for S1 and S0, which are virtual.
+ S4 s4;
+ S0 *s0 = &s4;
+ S1 *s1 = &s4;
+ S2 *s2 = &s4;
+ S3 *s3 = &s4;
+
+ if (vtable (&s4) != vtable (s2))
+ return 1;
+ if (vtable (s2) >= vtable (s3))
+ return 2;
+ if (vtable (s3) >= vtable (s1))
+ return 3;
+ if (vtable (s1) >= vtable (s0))
+ return 4;
+}
+
+#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/vtable2.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C
new file mode 100644
index 000000000..b64f0fc25
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C
@@ -0,0 +1,213 @@
+// { dg-do run }
+// { dg-options "-fno-strict-aliasing" }
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
+
+#include <stddef.h>
+
+struct S0
+{
+ virtual void s0 ();
+};
+
+struct S1 : virtual public S0
+{
+ virtual void s1 ();
+};
+
+struct S2 : virtual public S1
+{
+ virtual void s1 ();
+ virtual void s0 ();
+};
+
+struct S3
+{
+ virtual void s3 ();
+};
+
+struct S4 : public S3, virtual public S2
+{
+ virtual void s1 ();
+};
+
+void S0::s0 ()
+{
+}
+
+void S1::s1 ()
+{
+}
+
+void S2::s1 ()
+{
+}
+
+void S2::s0 ()
+{
+}
+
+void S3::s3 ()
+{
+}
+
+void S4::s1 ()
+{
+}
+
+/* The vtables should look like:
+
+ S0 primary vtable
+
+ S0 offset to top
+ S0 RTTI
+ S0::s0
+
+ =================
+
+ S1 primary vtable
+
+ S0::s0 vcall offset
+ S0 vbase offset
+ S1 offset to top
+ S1 RTTI
+ S0::s0
+ S1::s1
+
+ =================
+
+ S2 primary vtable
+
+ S2::s1 vcall offset
+ S1 vbase offset
+ S2::s0 vcall offset
+ S0 vbase offset
+ S2 offset to top
+ S2 RTTI
+ S2::s0
+ S2::s1
+
+ =================
+
+ S3 primary vtable
+
+ S3 offset to top
+ S3 RTTI
+ S3::s3
+
+ =================
+
+ S4 primary vtable
+
+ vbase offset for S0
+ vbase offset for S1
+ vbase offset for S2
+ S4 offset to top
+ S4 RTTI
+ S3::s3
+ S4::s1
+
+ S2-in-S4 secondary vtable
+
+ S1 vbase offset
+ S4::s1 vcall offset
+ S0 vbase offset
+ S2:s0 vcall offset
+ S2 offset to top
+ S4 RTTI
+ S2::s0
+ S4::s1
+
+*/
+
+// These are tricks to allow us to get raw function pointers for
+// member functions.
+extern "C" {
+ /* We can use weakref here without dg-require-weak, because we know
+ the symbols are defined, so we don't actually issue the .weak
+ directives. */
+ static void S3_s3 () __attribute__((__weakref__ ("_ZN2S32s3Ev")));
+ static void S4_s1 () __attribute__((__weakref__ ("_ZN2S42s1Ev")));
+}
+
+// IA-64 uses function descriptors not function pointers in its vtables.
+#if defined __ia64__
+#define CMP_VPTR(A, B) (*(void **)(A) == *(void **)(B))
+#ifdef _LP64
+#define INC_VPTR(A) ((A) += 2)
+#define INC_VDATA(A,N) ((A) += (N))
+#else
+#define INC_VPTR(A) ((A) += 4)
+#define INC_VDATA(A,N) ((A) += 2*(N))
+#endif
+#else
+#define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B))
+#define INC_VPTR(A) ((A) += 1)
+#define INC_VDATA(A,N) ((A) += (N))
+#endif
+
+int main ()
+{
+ S4 s4;
+ ptrdiff_t **vptr;
+ ptrdiff_t *vtbl;
+
+ // Set vtbl to point at the beginning of S4's primary vtable.
+ vptr = (ptrdiff_t **) &s4;
+ vtbl = *vptr;
+ INC_VDATA (vtbl, -5);
+
+ if (*vtbl != ((char*) (S0*) &s4) - (char*) &s4)
+ return 1;
+ INC_VDATA (vtbl, 1);
+ if (*vtbl != ((char*) (S1*) &s4) - (char*) &s4)
+ return 2;
+ INC_VDATA (vtbl, 1);
+ if (*vtbl != ((char*) (S2*) &s4) - (char*) &s4)
+ return 3;
+ INC_VDATA (vtbl, 1);
+ if (*vtbl != 0)
+ return 4;
+ INC_VDATA (vtbl, 1);
+ // Skip the RTTI entry.
+ INC_VDATA (vtbl, 1);
+ if (! CMP_VPTR (vtbl, &S3_s3))
+ return 5;
+ INC_VPTR (vtbl);
+ if (! CMP_VPTR (vtbl, &S4_s1))
+ return 6;
+ INC_VPTR (vtbl);
+ // The S1 vbase offset.
+ if (*vtbl != 0)
+ return 7;
+ INC_VDATA (vtbl, 1);
+ // The S4::s1 vcall offset is negative; once you convert to S2, you
+ // have to convert to S4 to find the final overrider.
+ if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4))
+ return 8;
+ INC_VDATA (vtbl, 1);
+ if (*vtbl != 0)
+ return 9;
+ INC_VDATA (vtbl, 1);
+ if (*vtbl != 0)
+ return 10;
+ INC_VDATA (vtbl, 1);
+ // Now we're at the S2 offset to top entry.
+ if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4))
+ return 11;
+ INC_VDATA (vtbl, 1);
+ // Skip the RTTI entry.
+ INC_VDATA (vtbl, 1);
+ // Skip the remaining virtual functions -- they are thunks.
+ INC_VPTR (vtbl);
+ INC_VPTR (vtbl);
+}
+
+#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/vtable3.h b/gcc/testsuite/g++.old-deja/g++.abi/vtable3.h
new file mode 100644
index 000000000..ef02456f2
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3.h
@@ -0,0 +1,179 @@
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check constructor vtables work. This is included from numerous test
+// files, which set the #defines necessary to specify the hierarchy.
+
+#include <typeinfo>
+#include <stdio.h>
+
+int fail;
+struct A;
+
+template <typename BASE, typename DERIVED>
+int Test (DERIVED *d, int expect)
+{
+ BASE *b = static_cast <BASE *> (d);
+ void *full_b = dynamic_cast <void *> (b);
+ void *full_d = dynamic_cast <void *> (d);
+ A *ap = static_cast <A *> (b);
+
+ if (full_b != full_d)
+ {
+ fail++;
+ fprintf (stderr, "base %s and derived %s have different full objects\n",
+ typeid (BASE).name (), typeid (DERIVED).name ());
+ return 1;
+ }
+
+ DERIVED *dynamic_d = dynamic_cast <DERIVED *> (b);
+
+ if (dynamic_d != d)
+ {
+ fail++;
+ fprintf (stderr, "dynamic_cast from %s to %s failed\n",
+ typeid (BASE).name (), typeid (DERIVED).name ());
+ return 1;
+ }
+
+ b->Baz (static_cast <void *> (ap));
+
+ int res = b->Foo (static_cast <void *> (d));
+
+ if (res != expect)
+ {
+ fail++;
+ fprintf (stderr, "%s::Foo returned %d, expected %d\n",
+ typeid (BASE).name (), res, expect);
+ return 1;
+ }
+
+ return 0;
+}
+
+template <typename T>
+int Test (T *self, void *expected, int result)
+{
+ if (self != expected)
+ {
+ fail++;
+ fprintf (stderr, "%s::Foo wrong this pointer\n", typeid (T).name ());
+ }
+ return result;
+}
+
+struct A {
+#ifndef A_EMPTY
+ int a_m;
+#endif
+ virtual int Foo (void *p) {return Test (this, p, 1);}
+ virtual int Baz (void *p) {return Test (this, p, 1);}
+ A ();
+ ~A ();
+};
+
+struct B1: virtual A {
+#ifndef B1_EMPTY
+ int b1_m;
+#endif
+ virtual int Foo (void *p) {return Test (this, p, 2);}
+ B1();
+ ~B1();
+};
+
+struct B2: virtual A {
+#ifndef B2_EMPTY
+ int b2_m;
+#endif
+ virtual int Foo (void *p) {return Test (this, p, 3);}
+ B2();
+ ~B2();
+};
+
+struct Empty {};
+
+struct C : C_PARENTS {
+#ifndef C_EMPTY
+ int c_m;
+#endif
+ virtual int Foo (void *p) {return Test (this, p, 4);}
+ C();
+ ~C();
+};
+
+A::A ()
+{
+ fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
+ Test <A> (this, 1);
+}
+A::~A ()
+{
+ fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
+ Test <A> (this, 1);
+}
+
+B1::B1()
+{
+ fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
+ Test <A> (this, 2);
+ Test <B1> (this, 2);
+}
+B1::~B1()
+{
+ fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
+ Test <A> (this, 2);
+ Test <B1> (this, 2);
+}
+B2::B2()
+{
+ fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
+ Test <A> (this, 3);
+ Test <B2> (this, 3);
+}
+B2::~B2()
+{
+ fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
+ Test <A> (this, 3);
+ Test <B2> (this, 3);
+}
+C::C()
+{
+ fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
+ Test <A> (this, 4);
+ Test <C> (this, 4);
+}
+C::~C()
+{
+ fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
+ Test <A> (this, 4);
+ Test <C> (this, 4);
+}
+
+struct D : C {};
+struct D1 : virtual C {};
+struct D2 : virtual A, virtual C {};
+
+int main()
+{
+ {
+ fprintf (stderr, "C\n");
+ C c;
+ }
+ {
+ fprintf (stderr, "D\n");
+ D d;
+ }
+ {
+ fprintf (stderr, "D1\n");
+ D1 d1;
+ }
+ {
+ fprintf (stderr, "D2\n");
+ D2 d2;
+ }
+ if (fail)
+ fprintf (stderr, "There are %d failings\n", fail);
+ else
+ fprintf (stderr, "Passed\n");
+ return fail ? 1 : 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3a.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3a.C
new file mode 100644
index 000000000..d2eaa562d
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3a.C
@@ -0,0 +1,23 @@
+// { dg-do run }
+// { dg-additional-files "vtable3.h" }
+
+// Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check constructor vtables work.
+
+#define A_EMPTY
+#define B1_EMPTY
+#define B2_EMPTY
+#define C_EMPTY
+#define C_PARENTS B1, B2
+
+#include "vtable3.h"
+
+/*
+ A = { vptr }
+ B1, B2 = { A }
+ C = { B1, B2 }
+ D = { C }
+ D1 = {
+ */
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3b.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3b.C
new file mode 100644
index 000000000..1a108f8cc
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3b.C
@@ -0,0 +1,14 @@
+// { dg-do run }
+// { dg-additional-files "vtable3.h" }
+
+// Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check constructor vtables work.
+
+#define B1_EMPTY
+#define B2_EMPTY
+#define C_EMPTY
+#define C_PARENTS B1, B2
+
+#include "vtable3.h"
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3c.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3c.C
new file mode 100644
index 000000000..c7b1365b6
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3c.C
@@ -0,0 +1,14 @@
+// { dg-do run }
+// { dg-additional-files "vtable3.h" }
+
+// Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check constructor vtables work.
+
+#define A_EMPTY
+#define B2_EMPTY
+#define C_EMPTY
+#define C_PARENTS B1, B2
+
+#include "vtable3.h"
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3d.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3d.C
new file mode 100644
index 000000000..82edae697
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3d.C
@@ -0,0 +1,14 @@
+// { dg-do run }
+// { dg-additional-files "vtable3.h" }
+
+// Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check constructor vtables work.
+
+#define A_EMPTY
+#define B1_EMPTY
+#define C_EMPTY
+#define C_PARENTS B1, B2
+
+#include "vtable3.h"
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3e.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3e.C
new file mode 100644
index 000000000..e8469cf42
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3e.C
@@ -0,0 +1,14 @@
+// { dg-do run }
+// { dg-additional-files "vtable3.h" }
+
+// Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check constructor vtables work.
+
+#define A_EMPTY
+#define B1_EMPTY
+#define B2_EMPTY
+#define C_PARENTS B1, B2
+
+#include "vtable3.h"
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3f.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3f.C
new file mode 100644
index 000000000..c604af889
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3f.C
@@ -0,0 +1,15 @@
+// { dg-do run }
+// { dg-additional-files "vtable3.h" }
+
+// Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check constructor vtables work.
+
+#define A_EMPTY
+#define B1_EMPTY
+#define B2_EMPTY
+#define C_EMPTY
+#define C_PARENTS B1, virtual B2
+
+#include "vtable3.h"
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3g.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3g.C
new file mode 100644
index 000000000..9218f4077
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3g.C
@@ -0,0 +1,15 @@
+// { dg-do run }
+// { dg-additional-files "vtable3.h" }
+
+// Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check constructor vtables work.
+
+#define A_EMPTY
+#define B1_EMPTY
+#define B2_EMPTY
+#define C_EMPTY
+#define C_PARENTS virtual B1, B2
+
+#include "vtable3.h"
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3h.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3h.C
new file mode 100644
index 000000000..1a756fe62
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3h.C
@@ -0,0 +1,15 @@
+// { dg-do run }
+// { dg-additional-files "vtable3.h" }
+
+// Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check constructor vtables work.
+
+#define A_EMPTY
+#define B1_EMPTY
+#define B2_EMPTY
+#define C_EMPTY
+#define C_PARENTS virtual B1, virtual B2
+
+#include "vtable3.h"
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3i.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3i.C
new file mode 100644
index 000000000..a71087bd4
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3i.C
@@ -0,0 +1,14 @@
+// { dg-do run }
+// { dg-additional-files "vtable3.h" }
+
+// Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check constructor vtables work.
+
+#define B1_EMPTY
+#define B2_EMPTY
+#define C_EMPTY
+#define C_PARENTS virtual B1, B2
+
+#include "vtable3.h"
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3j.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3j.C
new file mode 100644
index 000000000..de4f590de
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3j.C
@@ -0,0 +1,14 @@
+// { dg-do run }
+// { dg-additional-files "vtable3.h" }
+
+// Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
+
+// Check constructor vtables work.
+
+#define B1_EMPTY
+#define B2_EMPTY
+#define C_EMPTY
+#define C_PARENTS virtual B1, virtual B2
+
+#include "vtable3.h"