diff options
author | Jason Merrill <jason@redhat.com> | 2011-03-18 11:06:51 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-03-18 11:06:51 -0400 |
commit | b4ef8aac30e7c17756d6a1ad8cbd6c914e960bb4 (patch) | |
tree | 02f20ae0754332e0eef01c0e3956f0a4e49f08a4 /gcc/gimplify.c | |
parent | 82d3711899283500f82e917649cd3dc0457ba1a1 (diff) | |
download | gcc-b4ef8aac30e7c17756d6a1ad8cbd6c914e960bb4.zip gcc-b4ef8aac30e7c17756d6a1ad8cbd6c914e960bb4.tar.gz gcc-b4ef8aac30e7c17756d6a1ad8cbd6c914e960bb4.tar.bz2 |
re PR c++/23372 (Temporary aggregate copy not elided when passing parameters by value)
PR c++/23372
* gimplify.c (gimplify_arg): Strip redundant TARGET_EXPR.
From-SVN: r171146
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 400493f..0b314a0 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2255,7 +2255,17 @@ gimplify_arg (tree *arg_p, gimple_seq *pre_p, location_t call_location) if (is_gimple_reg_type (TREE_TYPE (*arg_p))) test = is_gimple_val, fb = fb_rvalue; else - test = is_gimple_lvalue, fb = fb_either; + { + test = is_gimple_lvalue, fb = fb_either; + /* Also strip a TARGET_EXPR that would force an extra copy. */ + if (TREE_CODE (*arg_p) == TARGET_EXPR) + { + tree init = TARGET_EXPR_INITIAL (*arg_p); + if (init + && !VOID_TYPE_P (TREE_TYPE (init))) + *arg_p = init; + } + } /* If this is a variable sized type, we must remember the size. */ maybe_with_size_expr (arg_p); |