add test case for warnings about overlapping initializers
[smatch.git] / validation / field-override.c
blobd5d00dfa8596feee2d6a1b50e96fafcadd1b4d5d
1 static int ref[] = {
2 [1] = 3,
3 [2] = 3,
4 [3] = 3,
5 [2] = 2, /* check-should-warn */
6 [1] = 1, /* check-should-warn */
7 };
9 static int foo[] = {
10 [1 ... 3] = 3,
13 static int foz[4] = {
14 [0 ... 3] = 3,
15 [0] = 0,
16 [1] = 0,
17 [2 ... 3] = 1,
18 [2] = 3, /* check-should-warn */
19 [3] = 3, /* check-should-warn */
22 static int bar[] = {
23 [1 ... 3] = 3,
24 [1] = 1, /* check-should-warn */
25 [2] = 2, /* check-should-warn */
26 [2 ... 4] = 2, /* check-should-warn */
27 [2 ... 3] = 2, /* check-should-warn */
28 [4] = 4, /* check-should-warn */
29 [0] = 0,
30 [5] = 5,
33 static int baz[3][3] = {
34 [0 ... 2][0 ... 2] = 0,
35 [0] = { 0, 0, 0, }, /* check-should-warn */
36 [0][0] = 1, /* check-should-warn */
37 [1] = { 0, 0, 0, }, /* check-should-warn */
38 [1][0] = 1, /* check-should-warn */
39 [1][1] = 1, /* check-should-warn */
40 [1 ... 2][1 ... 2] = 2,
44 struct s {
45 int i;
46 int a[2];
49 static struct s s = {
50 .a[0] = 0,
51 .a[1] = 1,
54 static struct s a[2] = {
55 [0].i = 0,
56 [1].i = 1,
57 [0].a[0] = 2,
58 [0].a[1] = 3,
61 static struct s b[2] = {
62 [0 ... 1] = { 0, { 1, 2 }, },
63 [0].i = 0,
64 [1].i = 1,
65 [0].a[0] = 2,
66 [0].a[1] = 3,
70 * check-name: field-override
71 * check-command: sparse -Woverride-init $file
72 * check-known-to-fail
74 * check-error-start
75 field-override.c:2:10: warning: Initializer entry defined twice
76 field-override.c:6:10: also defined here
77 field-override.c:14:10: warning: Initializer entry defined twice
78 field-override.c:15:10: also defined here
79 field-override.c:23:10: warning: Initializer entry defined twice
80 field-override.c:24:10: also defined here
81 field-override.c:23:10: warning: Initializer entry defined twice
82 field-override.c:25:10: also defined here
83 field-override.c:34:10: warning: Initializer entry defined twice
84 field-override.c:35:10: also defined here
85 field-override.c:62:10: warning: Initializer entry defined twice
86 field-override.c:63:10: also defined here
87 * check-error-end