From: will wray <wjwray@gmail.com>
To: Marek Polacek <polacek@redhat.com>
Cc: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] c++: designated init of char array by string constant [PR55227]
Date: Wed, 17 Nov 2021 22:23:58 -0500 [thread overview]
Message-ID: <CAKjnZWpMugbMppX+mYXMSxYH=jae+t=T9xt3TZ8Ma2wGSoKhnw@mail.gmail.com> (raw)
In-Reply-To: <CAKjnZWqiE=gmrgs6PuOJgMLi1eftKZbSwMO1f6tqFL9BgNUeZg@mail.gmail.com>
V2 Patch
https://gcc.gnu.org/bugzilla/attachment.cgi?id=51828
On Wed, Nov 17, 2021 at 10:06 PM will wray <wjwray@gmail.com> wrote:
>
> Thanks for the review Marek;
> I'll post the updated patch in a follow-on message and on bugzilla.
>
> On Mon, Nov 15, 2021 at 8:03 PM Marek Polacek <polacek@redhat.com> wrote:
>
> > I also noticed the C++ FE rejects
> >
> > struct A { char x[4]; };
> > struct B { struct A a; };
> > struct B b = { .a.x = "abc" };
> > but the C FE accepts it. But that's for another time.
>
> Yes, the nested case is invalid for C++, valid for C.
> c.f. cppreference aggregate init.
>
> > > + reshape_iter stripd = {};
> >
> > Since the previous variables spell it "stripped" maybe call it stripped_iter.
>
> I've left it as "stripd"; the top level reshape_iter is just "d", non-verbose,
> so "stripped_d" inappropriately over-verbose.
>
> > > @@ -6836,7 +6838,8 @@ reshape_init_r (tree type, reshape_iter *d, tree first_initializer_p,
> > > array types (one value per array element). */
> > > if (TREE_CODE (stripped_str_init) == STRING_CST)
> > > {
> > > - if (has_designator_problem (d, complain))
> >
> > So the logic here is that...
>
> Yes, you get the logic exactly... took me a few rounds to get it.
>
> > Nice to finally remove this, but let's keep this part of the comment.
>
> Agreed, and reinstated.
>
> > BRACE_ENCLOSED_INITIALIZER_P checks that it gets a CONSTRUCTOR so you
> > can remove the first check.
>
> Nice, thanks; missed that.
>
> > > +// { dg-do compile }
> > > +// { dg-options "-pedantic" }
> >
> > FWIW, if you remove the dg-options, -pedantic-errors will be used so you could
> > drop it and then use dg-error instead of dg-warning below but this is OK too.
>
> I'd copied that from another desigN.C test, now I've copied the simpler:
>
> +// { dg-options "" }
>
> and removed all of the noisy dg-warning tests
>
> > We should probably test more:
> > - nested structs
> > - anonymous unions
> > - test when the initializer is too long
> > - multidim arrays:
>
> Cut-n-paste'd your multidim array test, and added a couple more
>
> > Hope this is useful...
>
> Very useful, thanks again
next prev parent reply other threads:[~2021-11-18 3:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-07 0:17 Will Wray
2021-11-15 18:14 ` PING: " will wray
2021-11-16 1:03 ` Marek Polacek
2021-11-18 3:06 ` will wray
2021-11-18 3:23 ` will wray [this message]
2021-11-18 15:36 ` Marek Polacek
2021-11-18 20:50 ` will wray
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='CAKjnZWpMugbMppX+mYXMSxYH=jae+t=T9xt3TZ8Ma2wGSoKhnw@mail.gmail.com' \
--to=wjwray@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=polacek@redhat.com \
/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).