implied: use a time based timeout instead of counting ->nr_children
[smatch.git] / validation / initializer-entry-defined-twice.c
blob8a5bd3a95631808fb0c7a2583e2b5e3aa15e187b
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
46 * _Bools generally take a whole byte, so ensure that we can initialize
47 * them without spewing a warning.
49 static _Bool boolarray[3] = {
50 [0] = 1,
51 [1] = 1,
55 * check-name: Initializer entry defined twice
57 * check-error-start
58 initializer-entry-defined-twice.c:10:10: warning: Initializer entry defined twice
59 initializer-entry-defined-twice.c:11:10: also defined here
60 initializer-entry-defined-twice.c:26:18: warning: Initializer entry defined twice
61 initializer-entry-defined-twice.c:27:18: also defined here
62 * check-error-end