From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; 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. --- gcc/testsuite/g++.dg/rtti/dyncast3.C | 81 ++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 gcc/testsuite/g++.dg/rtti/dyncast3.C (limited to 'gcc/testsuite/g++.dg/rtti/dyncast3.C') diff --git a/gcc/testsuite/g++.dg/rtti/dyncast3.C b/gcc/testsuite/g++.dg/rtti/dyncast3.C new file mode 100644 index 000000000..08352599b --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/dyncast3.C @@ -0,0 +1,81 @@ +// This testcase used to crash while looking in A for my_module. I'm still +// not sure it's well-formed, but it works now because of the optimization +// to look at the expected address first. + +// { dg-do run } + +extern "C" int puts (const char *); +extern "C" void abort (); + +struct my_object +{ + my_object() { puts ("in my_object ctor");} + virtual ~my_object() { puts ("in my_object dtor"); } +}; + +my_object* my_module_ptr = 0; + +struct my_module : my_object +{ + my_module() + { + puts ("in my_module ctor, setting up ptr"); + my_module_ptr = this; + } + ~my_module() { puts ("in my_module dtor");} +}; + +struct D +{ + D() { puts ("in D ctor"); } + virtual ~D(); +}; + +D::~D() +{ + puts ("in D dtor"); + puts ("before DCASTing to my_module*"); + my_module* m = dynamic_cast(my_module_ptr); + if (m != my_module_ptr) + abort (); + puts ("after DCASTing to my_module*"); +} + +struct my_interface +{ + my_interface() { puts ("in my_interface ctor");} + ~my_interface() { puts ("in my_interface dtor");} +}; + +struct myif : virtual my_interface +{ + myif() { puts ("in myif ctor");} + ~myif() { puts ("in myif dtor");} +}; + +struct A: virtual myif +{ + A() { puts ("in A ctor"); } + ~A() { puts ("in A dtor"); } + + D d; +}; + +struct B: virtual myif +{ + B() { puts ("in B ctor"); } + ~B() { puts ("in B dtor"); } + + D d; +}; + +struct C : my_module, A, B +{ + C() { puts ("in C ctor");} + ~C() { puts ("in C dtor"); } +}; + +int main(int, char**) +{ + C t; +} -- cgit v1.2.3