xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_011.c (revision f4748aaa01faf324805f9747191535eb6600f82c)
1 /*	$NetBSD: msg_011.c,v 1.5 2021/08/26 19:23:25 rillig Exp $	*/
2 # 3 "msg_011.c"
3 
4 // Test for message: bit-field initializer out of range [11]
5 
6 void
7 example(void)
8 {
9 	struct {
10 		signed int si: 3;
11 		unsigned int ui: 3;
12 	} s[] = {
13 		/* expect+2: warning: bit-field initializer out of range [11] */
14 		/* expect+1: warning: initialization of unsigned with negative constant [221] */
15 		{ -8, -8 },
16 
17 		/* expect+2: warning: bit-field initializer out of range [11] */
18 		/* expect+1: warning: initialization of unsigned with negative constant [221] */
19 		{ -7, -7 },
20 
21 		/* expect+1: warning: initialization of unsigned with negative constant [221] */
22 		{ -4, -4 },
23 
24 		/* expect+1: warning: initialization of unsigned with negative constant [221] */
25 		{ -3, -3 },
26 
27 		{ 3, 3 },
28 
29 		/* expect+1: warning: bit-field initializer out of range [11] */
30 		{ 4, 4 },
31 
32 		/* expect+1: warning: bit-field initializer out of range [11] */
33 		{ 7, 7 },
34 
35 		/* expect+2: warning: bit-field initializer does not fit [180] */
36 		/* expect+1: warning: bit-field initializer does not fit [180] */
37 		{ 8, 8 },
38 	};
39 }
40