From ad4cc8eb72e6f8df386a51a2269089dca9714b1f Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 13 May 2014 12:05:19 -0400 Subject: [PATCH] re PR c++/60708 (An array temporary causes an ICE in gimplify) PR c++/60708 * call.c (build_array_conv): Call complete_type. From-SVN: r210384 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/call.c | 3 +++ gcc/testsuite/g++.dg/cpp0x/initlist82.C | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist82.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9d63170ac7eb..a31db4358d5f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2014-05-13 Jason Merrill + PR c++/60708 + * call.c (build_array_conv): Call complete_type. + PR c++/60713 * typeck2.c (PICFLAG_SIDE_EFFECTS): New. (picflag_from_initializer): Return it. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index db5a17fdf569..51e1d192958e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -943,6 +943,9 @@ build_array_conv (tree type, tree ctor, int flags, tsubst_flags_t complain) bool user = false; enum conversion_rank rank = cr_exact; + /* We might need to propagate the size from the element to the array. */ + complete_type (type); + if (TYPE_DOMAIN (type)) { unsigned HOST_WIDE_INT alen = tree_low_cst (array_type_nelts_top (type), 1); diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist82.C b/gcc/testsuite/g++.dg/cpp0x/initlist82.C new file mode 100644 index 000000000000..3b9ccad6667e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist82.C @@ -0,0 +1,20 @@ +// PR c++/60708 +// { dg-do compile { target c++11 } } + +template struct mypair { + mypair(T, U) {} +}; + +template struct S { + mypair get_pair() noexcept { + return mypair(nullptr, 0); + } +}; + +static void foo(const mypair (&a)[2]) noexcept { } + +int main() +{ + S s; + foo({s.get_pair(), s.get_pair()}); +} -- 2.47.2