From d7d5e42f2d03fb95b70b605a9c9a0488e0e1ba74 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Tue, 14 Dec 1999 18:52:40 +0000 Subject: [PATCH] cp-tree.h (remap_save_expr): Add walk_subtrees parameter. * cp-tree.h (remap_save_expr): Add walk_subtrees parameter. * optimize.c (copy_body_r): Pass it. * tree.c (remap_save_expr): Clear walk_subtrees for an already-handled SAVE_EXPR. (cp_unsave_r): Pass walk_subtrees to remap_save_expr. From-SVN: r30926 --- gcc/cp/ChangeLog | 6 +++ gcc/cp/cp-tree.h | 2 +- gcc/cp/optimize.c | 3 +- gcc/cp/tree.c | 9 +++- .../g++.old-deja/g++.other/inline3.C | 51 +++++++++++++++++++ 5 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/inline3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3f44c780f05..31b963e4b34 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 1999-12-14 Mark Mitchell + * cp-tree.h (remap_save_expr): Add walk_subtrees parameter. + * optimize.c (copy_body_r): Pass it. + * tree.c (remap_save_expr): Clear walk_subtrees for an + already-handled SAVE_EXPR. + (cp_unsave_r): Pass walk_subtrees to remap_save_expr. + * dump.c (dequeue_and_dump): Dump DECL_NAMESPACE_ALIAS. * ir.texi (DECL_NAMESPACE_ALIAS): Document it. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 90f652fae25..99b258077fe 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4064,7 +4064,7 @@ extern tree copy_tree_r PROTO((tree *, int *, void *)); extern int cp_valid_lang_attribute PROTO((tree, tree, tree, tree)); extern tree make_ptrmem_cst PROTO((tree, tree)); extern tree cp_build_qualified_type_real PROTO((tree, int, int)); -extern void remap_save_expr PROTO((tree *, splay_tree, tree)); +extern void remap_save_expr PROTO((tree *, splay_tree, tree, int *)); #define cp_build_qualified_type(TYPE, QUALS) \ cp_build_qualified_type_real ((TYPE), (QUALS), /*complain=*/1) diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index ee338869840..50ee83efe91 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -296,7 +296,8 @@ copy_body_r (tp, walk_subtrees, data) *tp = new_decl; } else if (TREE_CODE (*tp) == SAVE_EXPR) - remap_save_expr (tp, id->decl_map, VARRAY_TREE (id->fns, 0)); + remap_save_expr (tp, id->decl_map, VARRAY_TREE (id->fns, 0), + walk_subtrees); else if (TREE_CODE (*tp) == UNSAVE_EXPR) my_friendly_abort (19991113); /* For a SCOPE_STMT, we must copy the associated block so that we diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 31fbec0401c..c66d2fb54b2 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2659,10 +2659,11 @@ init_tree () ST. FN is the function into which the copy will be placed. */ void -remap_save_expr (tp, st, fn) +remap_save_expr (tp, st, fn, walk_subtrees) tree *tp; splay_tree st; tree fn; + int *walk_subtrees; { splay_tree_node n; @@ -2684,6 +2685,10 @@ remap_save_expr (tp, st, fn) (splay_tree_key) *tp, (splay_tree_value) t); } + else + /* We've already walked into this SAVE_EXPR, so we needn't do it + again. */ + *walk_subtrees = 0; /* Replace this SAVE_EXPR with the copy. */ *tp = (tree) n->value; @@ -2751,7 +2756,7 @@ cp_unsave_r (tp, walk_subtrees, data) *tp = (tree) n->value; } else if (TREE_CODE (*tp) == SAVE_EXPR) - remap_save_expr (tp, st, current_function_decl); + remap_save_expr (tp, st, current_function_decl, walk_subtrees); else { copy_tree_r (tp, walk_subtrees, NULL); diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline3.C b/gcc/testsuite/g++.old-deja/g++.other/inline3.C new file mode 100644 index 00000000000..ec3b33aac83 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline3.C @@ -0,0 +1,51 @@ +// Build don't link: +// Origin: Mark Mitchell +// Special g++ Options: -O3 + +class ostream; + +struct S +{ + virtual void print(ostream&) const = 0; +}; + +template +class vector +{ +public: + _Tp& operator[](unsigned __n) const { return *(_M_start + __n); } + _Tp* _M_start; +}; + +class T +{ +public: + + void print(ostream&) const; + + vector bcList_m; +}; + +void T::print(ostream& o) const +{ + int n = 3; + + for (int i = 0; i < n; ++i) + bcList_m[i]->print(o); + return; +} + +ostream& +operator<<(ostream& o, const T& bcList) +{ + bcList.print(o); + return o; +} + + + + + + + + -- 2.30.2