Home | History | Annotate | Line # | Download | only in lint1
      1 /*	$NetBSD: msg_034.c,v 1.6 2022/06/17 18:54:53 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: warning: nonportable bit-field type 'unsigned short' [34] */
     21 	unsigned short ushort: 1;
     22 
     23 	/* expect+1: warning: bit-field of type plain 'int' has implementation-defined signedness [344] */
     24 	int plain_int: 1;
     25 
     26 	signed int signed_int: 1;
     27 	unsigned int portable: 1;
     28 };
     29