xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_344.c (revision c83f7def18808bbacffe67311157403551f58f94)
1 /*	$NetBSD: msg_344.c,v 1.2 2022/06/17 18:54:53 rillig Exp $	*/
2 # 3 "msg_344.c"
3 
4 // Test for message: bit-field of type plain 'int' has implementation-defined signedness [344]
5 
6 /* lint1-extra-flags: -p */
7 
8 /*
9  * C90 3.5.2.1 allows 'int', 'signed int', 'unsigned int' as bit-field types.
10  *
11  * C99 6.7.2.1 significantly changed the wording of the allowable types for
12  * bit-fields.  For example, 6.7.2.1p4 does not mention plain 'int' at all.
13  * The rationale for C99 6.7.2.1 mentions plain 'int' though, and it would
14  * have broken a lot of existing code to disallow plain 'int' as a bit-field
15  * type.  Footnote 104 explicitly mentions plain 'int' as well and it even
16  * allows typedef-types for bit-fields.
17  */
18 struct example {
19 	/* expect+1: warning: bit-field of type plain 'int' has implementation-defined signedness [344] */
20 	int plain_int: 1;
21 
22 	signed int signed_int: 1;
23 	unsigned int unsigned_int: 1;
24 };
25