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