Module Name:    src
Committed By:   rillig
Date:           Tue Apr 19 22:14:30 UTC 2022

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_157.c msg_157.exp
        src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: only warn about unsigned constants in C90 migration mode

For C99 code, the difference between traditional C and C90 is not
relevant.

Seen in sqlite3.c line 30448.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_157.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_157.exp
cvs rdiff -u -r1.434 -r1.435 src/usr.bin/xlint/lint1/tree.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_157.c
diff -u src/tests/usr.bin/xlint/lint1/msg_157.c:1.3 src/tests/usr.bin/xlint/lint1/msg_157.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_157.c:1.3	Tue Mar 16 23:39:41 2021
+++ src/tests/usr.bin/xlint/lint1/msg_157.c	Tue Apr 19 22:14:30 2022
@@ -1,10 +1,13 @@
-/*	$NetBSD: msg_157.c,v 1.3 2021/03/16 23:39:41 rillig Exp $	*/
+/*	$NetBSD: msg_157.c,v 1.4 2022/04/19 22:14:30 rillig Exp $	*/
 # 3 "msg_157.c"
 
-// Test for message: ANSI C treats constant as unsigned [157]
+/* Test for message: ANSI C treats constant as unsigned [157] */
+
+/* lint1-flags: -w */
 
 /*
  * A rather strange definition for an ARGB color.
  * Luckily, 'double' has more than 32 significant binary digits.
  */
-double white = 0xFFFFFFFF;	/* expect: 157 */
+/* expect+1: warning: ANSI C treats constant as unsigned [157] */
+double white = 0xFFFFFFFF;

Index: src/tests/usr.bin/xlint/lint1/msg_157.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_157.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_157.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_157.exp:1.2	Tue Mar 16 23:39:41 2021
+++ src/tests/usr.bin/xlint/lint1/msg_157.exp	Tue Apr 19 22:14:30 2022
@@ -1 +1 @@
-msg_157.c(10): warning: ANSI C treats constant as unsigned [157]
+msg_157.c(13): warning: ANSI C treats constant as unsigned [157]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.434 src/usr.bin/xlint/lint1/tree.c:1.435
--- src/usr.bin/xlint/lint1/tree.c:1.434	Tue Apr 19 20:08:52 2022
+++ src/usr.bin/xlint/lint1/tree.c	Tue Apr 19 22:14:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.434 2022/04/19 20:08:52 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.435 2022/04/19 22:14:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.434 2022/04/19 20:08:52 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.435 2022/04/19 22:14:30 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -2644,10 +2644,10 @@ convert_constant(op_t op, int arg, const
 		nv->v_quad = v->v_quad;
 	}
 
-	if ((v->v_unsigned_since_c90 && is_floating(nt)) ||
-	    (v->v_unsigned_since_c90 && (is_integer(nt) && !is_uinteger(nt) &&
-			    portable_size_in_bits(nt) >
-			    portable_size_in_bits(ot)))) {
+	if (allow_trad && allow_c90 && v->v_unsigned_since_c90 &&
+	    (is_floating(nt) || (
+		(is_integer(nt) && !is_uinteger(nt) &&
+		 portable_size_in_bits(nt) > portable_size_in_bits(ot))))) {
 		/* ANSI C treats constant as unsigned */
 		warning(157);
 		v->v_unsigned_since_c90 = false;

Reply via email to