Re: Designated initializers for fields in anonymous structs and unions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Aug 2, 2014 at 12:53 PM, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Sat, Aug 2, 2014 at 11:10 AM, Linus Torvalds
> <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>>
>>> Actually, the "find_identifier" call inside function "check_designators" already
>>> calculate the correct offset. Only if we can pass that offset to
>>> "convert_ident()".
>>
>> I actu
> My stupid test-case is this incredibly hacky thing:
>
>     struct A {
>         int aa;
>         int bb;
>     };
>
>     struct S {
>         int a;
>         union {
>             int b;
>             int c;
>         } u[10];
>         int dummy;
>         union {
>             int d;
>             int e;
>         };
>     };
>
>     int fn(void)
>     {
>         struct S s = {
>             .a = 1,
>             .u[2].b = 2,
>             .dummy = 1,
>              { 3 }
>         };
>         return s.dummy*1000 + s.d*100 + s.u[2].b*10 + s.a; // 1321
>     }
>
> where I use "./test-linearize" to verify that the initializer layout
> matches the code generation layout (so that 'fn' function *should*
> linearize to just a simple "ret.32 $1321", and with this patch it
> does).
>
> But I bet this misses some case. However, the current state wrt
> initializer offsets really is very broken, so maybe it's ok.
>
> Can anybody see anything wrong with it? It's reasonably simple. Every
> place that initializes "expr->field" for an EXPR_IDENTIFIER now also
> initializes "expr->offset".

I did not see any thing wrong with it. The only thing is it bump up the
expression struct size. Definitely better than what we have right now.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux