aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2000-06-20 16:14:42 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2000-06-20 16:14:42 +0000
commit5f8f47513fd565e41816b5419054b229878393a8 (patch)
treecb9a4cd69d48c4c02b618dc9ba0fd0c5f08b6ed4
parent0f1e25b0d72e2ed1acda264536f5fa35df873bd2 (diff)
downloadgcc-5f8f47513fd565e41816b5419054b229878393a8.zip
gcc-5f8f47513fd565e41816b5419054b229878393a8.tar.gz
gcc-5f8f47513fd565e41816b5419054b229878393a8.tar.bz2
* g++.old-deja/g++.other/dyncast6.C: New test.
From-SVN: r34620
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/dyncast6.C72
2 files changed, 76 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ed8fe99d..5c6534f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2000-06-20 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.old-deja/g++.other/dyncast6.C: New test.
+
2000-06-15 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/execute/loop-6.c: New test.
diff --git a/gcc/testsuite/g++.old-deja/g++.other/dyncast6.C b/gcc/testsuite/g++.old-deja/g++.other/dyncast6.C
new file mode 100644
index 0000000..6ff219b
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/dyncast6.C
@@ -0,0 +1,72 @@
+// Special g++ Options: -w -ansi -pedantic-errors
+
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 20 June 2000 <nathan@codesourcery.com>
+
+// Origin GNATS bug report 143 from Carlo Wood <carlo@runaway.xs4all.nl>
+// We were generating incorrect type_info structures, and hence breaking
+// dynamic_cast.
+
+#include <stdio.h>
+
+class OBASE { public: virtual void bz () {}};
+class IBASE { public: virtual void by () {}};
+
+class V {public:int m; };
+
+class A : public virtual V { };
+class AA : public A {};
+
+class B : public OBASE, public A { public: virtual void foo(void) { } };
+class B1 : public OBASE, public AA { public: virtual void foo(void) { } };
+
+class C : public IBASE, public virtual V { };
+
+class D : public B, public C { };
+
+class E : public B, public virtual V { };
+
+class E1 : public B1, public virtual V {};
+
+class E2 : public B1, public A, public virtual V {};
+
+int main(void)
+{
+ D d;
+ E e;
+ E1 e1;
+ E2 e2;
+ int code = 0;
+
+ OBASE* osd = &d;
+ OBASE* ose = &e;
+ OBASE* ose1 = &e1;
+ OBASE* ose2 = &e2;
+
+
+ if (!dynamic_cast<V*>(osd))
+ {
+ printf ("fail osd\n");
+ code++;
+ }
+
+ if (!dynamic_cast<V*>(ose))
+ {
+ printf ("fail ose\n");
+ code++;
+ }
+
+ if (!dynamic_cast<V*>(ose1))
+ {
+ printf ("fail ose1\n");
+ code++;
+ }
+
+ if (!dynamic_cast<V*>(ose2))
+ {
+ printf ("fail ose2\n");
+ code++;
+ }
+
+ return code;
+}