This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: PR 25137: moving -Wmissing-braces to -Wextra?


Hi,

and first thanks everyone for the constructive feedbacks!
>> And recursively?
>>
>> So that:
>>
>> struct A { int i; };
>> struct B { struct A a };
>> struct C { struct B b };
>> struct C c = { 1 };
>>
>> does not trigger the warning?
>
> Sure.
>
>>
>> What if struct B is now:
>>
>> struct B { struct A a; int j; };
>>
>> and I write:
>>
>> struct C c = { 1, 2 };
>
> Then warn.
>
> I don't mind changing the behavior to not warn so long as all of the
> initializers missing braces apply to the same aggregate. So in the
> former case they all apply to struct A, whereas in the later case they
> do not.

I tried quickly drafting the corresponding patch, attached, which
appears to work pretty well (no regressions), please correct me as soon
as possible if I misunderstood. For example, this

struct S { int s[3]; };
struct S s1 = { 1, 1, 1 };

and this

struct S1 { int s[3]; };
struct S2 { struct S1 a; };
struct S2 s22 = { 1, 1, 1 };

and this

struct A { int i; };
struct B { struct A a };
struct C { struct B b };
struct C c = { 1 };

do not warn anymore. Whereas, this

struct S3 { int s[3]; };
struct S4 { struct S3 a; int b; };
struct S4 s23 = { 1, 1, 1 , 1 };

warns, but only about "missing braces around initializer for ‘S3’", not
about "missing braces around initializer for ‘int [3]’", at variance
with mainline. Changed the following way doesn't warn:

struct S5 { int s[3]; };
struct S5 { struct S5 a; int b; };
struct S5 s34 = { { 1, 1, 1 }, 1 };

This

struct A1 { int i; };
struct B1 { struct A1 a; };
struct B1 { struct A1 a; int j; };
struct C1 { struct B1 b; };
struct C1 c2 = { 1, 2 };

likewise only warns about "missing braces around initializer for ‘A1’"

In case, the same kind of change should be implemented in the C
front-end, right?

Thanks,
Paolo.

Attachment: d
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]