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 <pola...@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

Reply via email to