diff options
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/rtti.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/rtti/dyncast2.C | 31 |
4 files changed, 43 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 294be3a..f55b06a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-12-11 Jakub Jelinek <jakub@redhat.com> + + PR c++/34364 + * rtti.c (build_dynamic_cast): Call convert_from_reference even for + dynamic_cast in a template. + 2007-12-10 Simon Martin <simartin@users.sourceforge.net> PR c++/34059 diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 92cddbf..6cac0ef 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -728,8 +728,7 @@ build_dynamic_cast (tree type, tree expr) { expr = build_min (DYNAMIC_CAST_EXPR, type, expr); TREE_SIDE_EFFECTS (expr) = 1; - - return expr; + return convert_from_reference (expr); } return convert_from_reference (build_dynamic_cast_1 (type, expr)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 33e5663..663a059 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-12-11 Jakub Jelinek <jakub@redhat.com> + + PR c++/34364 + * g++.dg/rtti/dyncast2.C: New test. + 2007-12-11 Uros Bizjak <ubizjak@gmail.com> PR tree-optimization/34407 diff --git a/gcc/testsuite/g++.dg/rtti/dyncast2.C b/gcc/testsuite/g++.dg/rtti/dyncast2.C new file mode 100644 index 0000000..2e4f615 --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/dyncast2.C @@ -0,0 +1,31 @@ +// PR c++/34364 +// { dg-do run } + +struct A +{ + virtual ~A () {} +}; + +struct B : public A +{ + template <typename T> struct C + { + static void f (A &a) + { + dynamic_cast <B &>(a).g (); + } + }; + + B () : c (6) {} + void g () { c++; } + int c; +}; + +B b; + +int +main (void) +{ + B::C<int>::f (b); + return b.c != 7; +} |