cp-tree.h (remap_save_expr): Add walk_subtrees parameter.
authorMark Mitchell <mark@codesourcery.com>
Tue, 14 Dec 1999 18:52:40 +0000 (18:52 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 14 Dec 1999 18:52:40 +0000 (18:52 +0000)
* 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
gcc/cp/cp-tree.h
gcc/cp/optimize.c
gcc/cp/tree.c
gcc/testsuite/g++.old-deja/g++.other/inline3.C [new file with mode: 0644]

index 3f44c780f057c6234b8c5ea9d6b0a6374851478d..31b963e4b340a5cc8bb4cd119d4a04bc8722f454 100644 (file)
@@ -1,5 +1,11 @@
 1999-12-14  Mark Mitchell  <mark@codesourcery.com>
 
+       * 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.
 
index 90f652fae2550c2f1a65072a679af10191a25e06..99b258077fe6f1d546e84ef98455bb8dfed54089 100644 (file)
@@ -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)
 
index ee33886984042586bb77acb32f048c2497a4f046..50ee83efe91bbd0cba1a4f393deffbdaf4d656f0 100644 (file)
@@ -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
index 31fbec0401c07b9fdbe4300cee287ba8ca2c9c98..c66d2fb54b2da9d7fac99a5a121057c1b404d097 100644 (file)
@@ -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 (file)
index 0000000..ec3b33a
--- /dev/null
@@ -0,0 +1,51 @@
+// Build don't link: 
+// Origin: Mark Mitchell <mark@codesourcery.com>
+// Special g++ Options: -O3
+
+class ostream;
+
+struct S
+{
+  virtual void print(ostream&) const = 0;
+};
+
+template <class _Tp>
+class vector
+{
+public:
+  _Tp& operator[](unsigned __n) const { return *(_M_start + __n); }
+  _Tp* _M_start;
+};
+
+class T
+{
+public:
+
+  void print(ostream&) const;
+
+  vector<S*> 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;
+}
+
+