Module Name:    src
Committed By:   rillig
Date:           Sun May 16 10:34:19 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_034.c msg_034.exp msg_166.exp
        src/usr.bin/xlint/lint1: decl.c err.c

Log Message:
lint: add type information to unportable bit-field type

Seeing the message "unportable bit-field type 'int'" may sound strange
at first, but that's a strict interpretation of the wording in C99
6.7.2.1p4, which requires that the bit-field type is "'_Bool', 'unsigned
int' or 'signed int', or some other implementation-defined type".

The rationale for C99 6.7.2.1 explicitly lists plain 'int' among the
allowed types for bit-fields, regardless of any additional
implementation-defined types.  This means that lint had interpreted this
paragraph wrong, and it should be fixed to allow plain int as well.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_034.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_034.exp \
    src/tests/usr.bin/xlint/lint1/msg_166.exp
cvs rdiff -u -r1.180 -r1.181 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xlint/lint1/err.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_034.c
diff -u src/tests/usr.bin/xlint/lint1/msg_034.c:1.3 src/tests/usr.bin/xlint/lint1/msg_034.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_034.c:1.3	Sun Jan 31 11:12:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_034.c	Sun May 16 10:34:19 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: msg_034.c,v 1.3 2021/01/31 11:12:07 rillig Exp $	*/
+/*	$NetBSD: msg_034.c,v 1.4 2021/05/16 10:34:19 rillig Exp $	*/
 # 3 "msg_034.c"
 
-// Test for message: nonportable bit-field type [34]
+// Test for message: nonportable bit-field type '%s' [34]
 
 /* lint1-flags: -S -g -p -w */
 

Index: src/tests/usr.bin/xlint/lint1/msg_034.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_034.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_034.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_034.exp:1.2	Sun Jan  3 15:35:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_034.exp	Sun May 16 10:34:19 2021
@@ -1 +1 @@
-msg_034.c(9): warning: nonportable bit-field type [34]
+msg_034.c(9): warning: nonportable bit-field type 'int' [34]
Index: src/tests/usr.bin/xlint/lint1/msg_166.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_166.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_166.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_166.exp:1.2	Sun Jan 31 13:11:08 2021
+++ src/tests/usr.bin/xlint/lint1/msg_166.exp	Sun May 16 10:34:19 2021
@@ -1,5 +1,5 @@
-msg_166.c(25): warning: nonportable bit-field type [34]
-msg_166.c(26): warning: nonportable bit-field type [34]
+msg_166.c(25): warning: nonportable bit-field type 'int' [34]
+msg_166.c(26): warning: nonportable bit-field type 'int' [34]
 msg_166.c(35): warning: precision lost in bit-field assignment [166]
 msg_166.c(38): warning: precision lost in bit-field assignment [166]
 msg_166.c(39): warning: precision lost in bit-field assignment [166]

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.180 src/usr.bin/xlint/lint1/decl.c:1.181
--- src/usr.bin/xlint/lint1/decl.c:1.180	Sun May  2 22:07:49 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sun May 16 10:34:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.180 2021/05/02 22:07:49 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.181 2021/05/16 10:34:19 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.180 2021/05/02 22:07:49 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.181 2021/05/16 10:34:19 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1106,14 +1106,14 @@ check_bit_field_type(sym_t *dsym,  type_
 				/* bit-field type '%s' invalid in ANSI C */
 				warning(273, type_name(tp));
 			} else if (pflag) {
-				/* nonportable bit-field type */
-				warning(34);
+				/* nonportable bit-field type '%s' */
+				warning(34, type_name(tp));
 			}
 		}
 	} else if (t == INT && dcs->d_sign_mod == NOTSPEC) {
 		if (pflag && !bitfieldtype_ok) {
-			/* nonportable bit-field type */
-			warning(34);
+			/* nonportable bit-field type '%s' */
+			warning(34, type_name(tp));
 		}
 	} else if (t != INT && t != UINT && t != BOOL) {
 		/*

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.117 src/usr.bin/xlint/lint1/err.c:1.118
--- src/usr.bin/xlint/lint1/err.c:1.117	Sun May 16 10:18:24 2021
+++ src/usr.bin/xlint/lint1/err.c	Sun May 16 10:34:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.117 2021/05/16 10:18:24 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.118 2021/05/16 10:34:19 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.117 2021/05/16 10:18:24 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.118 2021/05/16 10:34:19 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -88,7 +88,7 @@ const char *const msgs[] = {
 	"incomplete structure or union %s: %s",			      /* 31 */
 	"argument type defaults to 'int': %s",			      /* 32 */
 	"duplicate member name: %s",				      /* 33 */
-	"nonportable bit-field type",				      /* 34 */
+	"nonportable bit-field type '%s'",			      /* 34 */
 	"illegal bit-field type '%s'",				      /* 35 */
 	"illegal bit-field size: %d",				      /* 36 */
 	"zero size bit-field",					      /* 37 */

Reply via email to