sparse, llvm: Use LLVMInt1Type() in sym_basetype_type()
[smatch.git] / validation / initializer-entry-defined-twice.c
blob968e3dd1af2a890b08b73cf610277f057ab065fd
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
45 * check-name: Initializer entry defined twice
47 * check-error-start
48 initializer-entry-defined-twice.c:10:10: warning: Initializer entry defined twice
49 initializer-entry-defined-twice.c:11:10: also defined here
50 initializer-entry-defined-twice.c:26:18: warning: Initializer entry defined twice
51 initializer-entry-defined-twice.c:27:18: also defined here
52 * check-error-end