xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_034.c (revision 53d1339bf7f9c7367b35a9e1ebe693f9b047a47b)
1 /*	$NetBSD: msg_034.c,v 1.5 2021/05/16 11:11:37 rillig Exp $	*/
2 # 3 "msg_034.c"
3 
4 // Test for message: nonportable bit-field type '%s' [34]
5 
6 /* No -g since GCC allows all integer types as bit-fields. */
7 /* lint1-flags: -S -p -w */
8 
9 /*
10  * C90 3.5.2.1 allows 'int', 'signed int', 'unsigned int' as bit-field types.
11  *
12  * C99 6.7.2.1 significantly changed the wording of the allowable types for
13  * bit-fields.  For example, 6.7.2.1p4 does not mention plain 'int' at all.
14  * The rationale for C99 6.7.2.1 mentions plain int though, and it would have
15  * broken a lot of existing code to disallow plain 'int' as a bit-field type.
16  * Footnote 104 explicitly mentions plain 'int' as well and it even allows
17  * typedef-types for bit-fields.
18  */
19 struct example {
20 	/* expect+1: 34 */
21 	unsigned short ushort: 1;
22 
23 	/* expect+1: 344 */
24 	int plain_int: 1;
25 
26 	signed int signed_int: 1;
27 	unsigned int portable: 1;
28 };
29