validation: Update comments for current Sparse behavior and test-suite.
[smatch.git] / validation / initializer-entry-defined-twice.c
blob6c48c52b1caad1b1d68e352922150710d3594f09
1 /* Tests for the "Initializer entry defined twice" warning. */
3 /* Initializing a struct field twice should trigger the warning. */
4 struct normal {
5 int field1;
6 int field2;
7 };
9 static struct normal struct_error = {
10 .field1 = 0,
11 .field1 = 0
14 /* Initializing two different fields of a union should trigger the warning. */
15 struct has_union {
16 int x;
17 union {
18 int a;
19 int b;
20 } y;
21 int z;
24 static struct has_union union_error = {
25 .y = {
26 .a = 0,
27 .b = 0
31 /* Empty structures can make two fields have the same offset in a struct.
32 * Initializing both should not trigger the warning. */
33 struct empty { };
35 struct same_offset {
36 struct empty field1;
37 int field2;
40 static struct same_offset not_an_error = {
41 .field1 = { },
42 .field2 = 0