summaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-26 21:13:23 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-26 21:13:23 +0000
commiteb5d9b7b56ef66787a2052d4deb04a675eb9b2c9 (patch)
tree215d3cb4dc23743144db979c43a787f2ed6b3027 /gcc/cp/call.c
parent91da4ab2b97e817bc02fcde53cc8c5f195b5fe61 (diff)
downloadgcc-eb5d9b7b56ef66787a2052d4deb04a675eb9b2c9.tar.gz
PR c++/53220
gcc/ * c-typeck.c (array_to_pointer_conversion): Give -Wc++-compat warning about array compound literals. gcc/cp/ * call.c (convert_like_real) [ck_list]: Take array address directly. * typeck.c (decay_conversion): Reject decay of an array compound literal. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187916 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index daaae2b6ead..5efa57cd759 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -5849,11 +5849,15 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
(elttype, cp_type_quals (elttype) | TYPE_QUAL_CONST);
array = build_array_of_n_type (elttype, len);
array = finish_compound_literal (array, new_ctor, complain);
+ /* Take the address explicitly rather than via decay_conversion
+ to avoid the error about taking the address of a temporary. */
+ array = cp_build_addr_expr (array, complain);
+ array = cp_convert (build_pointer_type (elttype), array);
/* Build up the initializer_list object. */
totype = complete_type (totype);
field = next_initializable_field (TYPE_FIELDS (totype));
- CONSTRUCTOR_APPEND_ELT (vec, field, decay_conversion (array, complain));
+ CONSTRUCTOR_APPEND_ELT (vec, field, array);
field = next_initializable_field (DECL_CHAIN (field));
CONSTRUCTOR_APPEND_ELT (vec, field, size_int (len));
new_ctor = build_constructor (totype, vec);