aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-09-20 15:37:57 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-09-20 15:37:57 -0400
commita4d25b444ddd3e7bede9de07530116456b9e69a8 (patch)
treea3bb743bf4f077e62aa102d85b6214ee2a127845
parentc067f4dbc095a2471388aadcf7632520b482f60e (diff)
downloadgcc-a4d25b444ddd3e7bede9de07530116456b9e69a8.zip
gcc-a4d25b444ddd3e7bede9de07530116456b9e69a8.tar.gz
gcc-a4d25b444ddd3e7bede9de07530116456b9e69a8.tar.bz2
call.c (convert_default_arg): Avoid redundant copy.
* call.c (convert_default_arg): Avoid redundant copy. * tree.c (bot_manip): Copy everything. From-SVN: r179016
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/call.c10
-rw-r--r--gcc/cp/tree.c12
3 files changed, 15 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b85e16c..da3f491 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2011-09-20 Jason Merrill <jason@redhat.com>
+
+ * call.c (convert_default_arg): Avoid redundant copy.
+ * tree.c (bot_manip): Copy everything.
+
2011-09-20 Roberto Agostino Vitillo <ravitillo@lbl.gov>
* call.c (build_new_method_call_1): Use non-virtual lookup
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 873b48b..b616cff 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6130,6 +6130,8 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum)
we must not perform access checks here. */
push_deferring_access_checks (dk_no_check);
+ /* We must make a copy of ARG, in case subsequent processing
+ alters any part of it. */
arg = break_out_target_exprs (arg);
if (TREE_CODE (arg) == CONSTRUCTOR)
{
@@ -6140,14 +6142,6 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum)
}
else
{
- /* We must make a copy of ARG, in case subsequent processing
- alters any part of it. For example, during gimplification a
- cast of the form (T) &X::f (where "f" is a member function)
- will lead to replacing the PTRMEM_CST for &X::f with a
- VAR_DECL. We can avoid the copy for constants, since they
- are never modified in place. */
- if (!CONSTANT_CLASS_P (arg))
- arg = unshare_expr (arg);
arg = convert_for_initialization (0, type, arg, LOOKUP_IMPLICIT,
ICR_DEFAULT_ARGUMENT, fn, parmnum,
tf_warning_or_error);
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 9987953..a9e1a26 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1865,9 +1865,13 @@ bot_manip (tree* tp, int* walk_subtrees, void* data)
if (!TYPE_P (t) && TREE_CONSTANT (t) && !TREE_SIDE_EFFECTS (t))
{
- /* There can't be any TARGET_EXPRs or their slot variables below
- this point. */
+ /* There can't be any TARGET_EXPRs or their slot variables below this
+ point. But we must make a copy, in case subsequent processing
+ alters any part of it. For example, during gimplification a cast
+ of the form (T) &X::f (where "f" is a member function) will lead
+ to replacing the PTRMEM_CST for &X::f with a VAR_DECL. */
*walk_subtrees = 0;
+ *tp = unshare_expr (t);
return NULL_TREE;
}
if (TREE_CODE (t) == TARGET_EXPR)
@@ -1928,8 +1932,8 @@ bot_replace (tree* t,
/* When we parse a default argument expression, we may create
temporary variables via TARGET_EXPRs. When we actually use the
- default-argument expression, we make a copy of the expression, but
- we must replace the temporaries with appropriate local versions. */
+ default-argument expression, we make a copy of the expression
+ and replace the temporaries with appropriate local versions. */
tree
break_out_target_exprs (tree t)