From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id C07B43853579; Sat, 1 Oct 2022 04:15:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C07B43853579 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664597743; bh=qgT2QZGpitWVPrDJl4U/g5u2/bHSu9Qzz2G+igPR7RE=; h=From:To:Subject:Date:From; b=UYDL5Q8q660uEKvgp+VfNaIpGxKDfCcAcoGeX89zrifX+AJBc5BHCz78n5lRT6dNK tS/uQO1m831s8rM0WVBiRRTxIQgAtGjSuanidwHkbwh5YiBeQi0GYAFhaw0lAeXwbO CryVtJT9oIjXn6XWvbudNDUTD8tI4H2twmeaKXmc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3009] c++: loop through array CONSTRUCTOR X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/master X-Git-Oldrev: f8cb417d6a4e2912d15a6d8bdffd1548cc649b49 X-Git-Newrev: dd9c8f644f0f1ac2000108ac369b991664946304 Message-Id: <20221001041543.C07B43853579@sourceware.org> Date: Sat, 1 Oct 2022 04:15:43 +0000 (GMT) List-Id: https://gcc.gnu.org/g:dd9c8f644f0f1ac2000108ac369b991664946304 commit r13-3009-gdd9c8f644f0f1ac2000108ac369b991664946304 Author: Jason Merrill Date: Tue Sep 20 16:06:26 2022 -0400 c++: loop through array CONSTRUCTOR I noticed that we were ignoring all the special rules for when to use a simple INIT_EXPR for array initialization from a CONSTRUCTOR, because split_nonconstant_init_1 was also passing 1 to the from_array parameter. Arguably that's the real bug, but I think we can be flexible. The test that I noticed this with no longer fails without it. gcc/cp/ChangeLog: * init.cc (build_vec_init): Clear from_array for CONSTRUCTOR initializer. Diff: --- gcc/cp/init.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index a85c3032130..bf46578c08b 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -4394,6 +4394,10 @@ build_vec_init (tree base, tree maxindex, tree init, } } + /* from_array doesn't apply to initialization from CONSTRUCTOR. */ + if (init && TREE_CODE (init) == CONSTRUCTOR) + from_array = 0; + /* If we have a braced-init-list or string constant, make sure that the array is big enough for all the initializers. */ bool length_check = (init @@ -4493,7 +4497,7 @@ build_vec_init (tree base, tree maxindex, tree init, /* If initializing one array from another, initialize element by element. We rely upon the below calls to do the argument checking. Evaluate the initializer before entering the try block. */ - if (from_array && init && TREE_CODE (init) != CONSTRUCTOR) + if (from_array) { if (lvalue_kind (init) & clk_rvalueref) xvalue = true;