linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Designated initializers for fields in anonymous structs and unions
@ 2014-07-31 18:10 josh
  2014-07-31 18:39 ` Linus Torvalds
  2014-08-01  2:19 ` Linus Torvalds
  0 siblings, 2 replies; 17+ messages in thread
From: josh @ 2014-07-31 18:10 UTC (permalink / raw)
  To: linux-sparse

GCC 4.6 and newer support initializing designated initializers for fields in
anonymous structs and unions.  However, sparse does not.  Test case:

union U {
    int a;
    struct {
        int b;
        int c;
    };
};

static union U u = {
    .b = 0,
    .c = 0,
};

struct S {
    int a;
    union {
        int b;
        int c;
    };
};

static struct S s = {
    .a = 0,
    .b = 0,
};



GCC handles this just fine; sparse says:

test.c:10:6: error: unknown field name in initializer
test.c:11:6: error: unknown field name in initializer
test.c:24:6: error: unknown field name in initializer

Sparse needs to handle this, and we should add the above as a test case.

(We also need an appropriate extension to the test for
__attribute__((designated_init)).)

- Josh Triplett

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2014-08-06  9:15 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-31 18:10 Designated initializers for fields in anonymous structs and unions josh
2014-07-31 18:39 ` Linus Torvalds
2014-07-31 18:50   ` Linus Torvalds
2014-07-31 20:55     ` josh
2014-08-02  8:27     ` Christopher Li
2014-08-02 18:09       ` Christopher Li
2014-08-01  2:19 ` Linus Torvalds
2014-08-01  2:41   ` Linus Torvalds
2014-08-02  1:16     ` Linus Torvalds
2014-08-02  5:16       ` Christopher Li
2014-08-02 18:10         ` Linus Torvalds
2014-08-02 18:31           ` Derek M Jones
2014-08-02 18:40             ` Christopher Li
2014-08-02 19:53           ` Linus Torvalds
2014-08-02 20:09             ` Linus Torvalds
2014-08-06  9:15             ` Christopher Li
2014-08-01  2:41   ` Josh Triplett

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 NNTP newsgroup(s).