From 7de77c9e9429bd583cda7fda511efc76946aa600 Mon Sep 17 00:00:00 2001 From: mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Tue, 21 Mar 2000 20:13:06 +0000 Subject: [PATCH] * tree.c (mark_local_for_remap_p): Mark variables declared in TARGET_EXPRs as well. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@32675 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 5 +++ gcc/cp/tree.c | 24 ++++++----- gcc/testsuite/g++.old-deja/g++.other/dtor7.C | 42 ++++++++++++++++++++ 3 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/dtor7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 79297e3b60d3..ed2316479b03 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-03-21 Mark Mitchell <mark@codesourcery.com> + + * tree.c (mark_local_for_remap_p): Mark variables declared in + TARGET_EXPRs as well. + 2000-03-21 Nathan Sidwell <nathan@codesourcery.com> * typeck.c (require_complete_type, complete_type, diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 84c7f3f04705..1409020e8714 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2317,18 +2317,24 @@ mark_local_for_remap_r (tp, walk_subtrees, data) { tree t = *tp; splay_tree st = (splay_tree) data; + tree decl; - if ((TREE_CODE (t) == DECL_STMT - && nonstatic_local_decl_p (DECL_STMT_DECL (t))) - || TREE_CODE (t) == LABEL_STMT) + + if (TREE_CODE (t) == DECL_STMT + && nonstatic_local_decl_p (DECL_STMT_DECL (t))) + decl = DECL_STMT_DECL (t); + else if (TREE_CODE (t) == LABEL_STMT) + decl = LABEL_STMT_LABEL (t); + else if (TREE_CODE (t) == TARGET_EXPR + && nonstatic_local_decl_p (TREE_OPERAND (t, 0))) + decl = TREE_OPERAND (t, 0); + else + decl = NULL_TREE; + + if (decl) { - tree decl; tree copy; - /* Figure out what's being declared. */ - decl = (TREE_CODE (t) == DECL_STMT - ? DECL_STMT_DECL (t) : LABEL_STMT_LABEL (t)); - /* Make a copy. */ copy = copy_decl_for_inlining (decl, DECL_CONTEXT (decl), @@ -2344,7 +2350,7 @@ mark_local_for_remap_r (tp, walk_subtrees, data) } /* Called via walk_tree when an expression is unsaved. Using the - splay_tree pointed to by ST (which is really a `splay_tree *'), + splay_tree pointed to by ST (which is really a `splay_tree'), remaps all local declarations to appropriate replacements. */ static tree diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor7.C b/gcc/testsuite/g++.old-deja/g++.other/dtor7.C new file mode 100644 index 000000000000..f1148afdd065 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor7.C @@ -0,0 +1,42 @@ +// Origin: Mark Mitchell <mitchell@codesourcery.com> +// Special g++ Options: -O2 + +int i; +int j; + +struct A +{ + A (); + A (const A&); + ~A (); +}; + +A::A () +{ + ++i; +} + +A::A (const A&) +{ + ++i; +} + +A::~A () +{ + --i; +} + +A f () +{ + return A (); +} + +void g (const A&) +{ +} + +int main () +{ + g (f ()); + return i; +} -- GitLab