summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.abi/vbase4.C
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/vbase4.C
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/vbase4.C')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/vbase4.C166
1 files changed, 166 insertions, 0 deletions
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;
+}