Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: only warn about unsigned constants...
details: https://anonhg.NetBSD.org/src/rev/ca4d62a28457
branches: trunk
changeset: 365709:ca4d62a28457
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Apr 19 22:14:30 2022 +0000
description:
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.
diffstat:
tests/usr.bin/xlint/lint1/msg_157.c | 9 ++++++---
tests/usr.bin/xlint/lint1/msg_157.exp | 2 +-
usr.bin/xlint/lint1/tree.c | 12 ++++++------
3 files changed, 13 insertions(+), 10 deletions(-)
diffs (59 lines):
diff -r 79d6e680651f -r ca4d62a28457 tests/usr.bin/xlint/lint1/msg_157.c
--- a/tests/usr.bin/xlint/lint1/msg_157.c Tue Apr 19 22:00:53 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_157.c Tue Apr 19 22:14:30 2022 +0000
@@ -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;
diff -r 79d6e680651f -r ca4d62a28457 tests/usr.bin/xlint/lint1/msg_157.exp
--- a/tests/usr.bin/xlint/lint1/msg_157.exp Tue Apr 19 22:00:53 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_157.exp Tue Apr 19 22:14:30 2022 +0000
@@ -1,1 +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]
diff -r 79d6e680651f -r ca4d62a28457 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Tue Apr 19 22:00:53 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c Tue Apr 19 22:14:30 2022 +0000
@@ -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 @@
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;
Home |
Main Index |
Thread Index |
Old Index