From: Jason Merrill <jason@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [pushed] c++: loop through array CONSTRUCTOR
Date: Sat, 1 Oct 2022 00:15:02 -0400 [thread overview]
Message-ID: <20221001041502.2211988-1-jason@redhat.com> (raw)
Tested x86_64-pc-linux-gnu, applying to trunk.
-- >8 --
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.
---
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;
base-commit: aa360fbf68b11e54017e8fa5b1bdb87ce7c19188
prerequisite-patch-id: 69446a92a4457ed77776068289cdcdb5a4c74b4d
--
2.31.1
reply other threads:[~2022-10-01 4:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221001041502.2211988-1-jason@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).