From eb5d9b7b56ef66787a2052d4deb04a675eb9b2c9 Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 26 May 2012 21:13:23 +0000 Subject: 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 --- gcc/cp/call.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gcc/cp/call.c') 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); -- cgit v1.2.1