From 2ed4c0297fb2ece975c69d17e02eac8d8b62325b Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 16 Jun 2015 15:29:09 -0400 Subject: re PR c++/58063 (default arguments evaluated twice per call) PR c++/58063 * tree.c (bot_manip): Remap SAVE_EXPR. From-SVN: r224533 --- gcc/cp/tree.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 3553d7c..a52e6f4 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2423,6 +2423,29 @@ bot_manip (tree* tp, int* walk_subtrees, void* data) *walk_subtrees = 0; return NULL_TREE; } + if (TREE_CODE (*tp) == SAVE_EXPR) + { + t = *tp; + splay_tree_node n = splay_tree_lookup (target_remap, + (splay_tree_key) t); + if (n) + { + *tp = (tree)n->value; + *walk_subtrees = 0; + } + else + { + copy_tree_r (tp, walk_subtrees, NULL); + splay_tree_insert (target_remap, + (splay_tree_key)t, + (splay_tree_value)*tp); + /* Make sure we don't remap an already-remapped SAVE_EXPR. */ + splay_tree_insert (target_remap, + (splay_tree_key)*tp, + (splay_tree_value)*tp); + } + return NULL_TREE; + } /* Make a copy of this node. */ t = copy_tree_r (tp, walk_subtrees, NULL); -- cgit v1.1