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: don't warn about comparison betwee...
details: https://anonhg.NetBSD.org/src/rev/c06f3ae827cd
branches: trunk
changeset: 376617:c06f3ae827cd
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jun 24 17:50:31 2023 +0000
description:
lint: don't warn about comparison between char and character constant
diffstat:
tests/usr.bin/xlint/lint1/msg_230.c | 10 ++--------
tests/usr.bin/xlint/lint1/msg_230_uchar.c | 10 ++--------
usr.bin/xlint/lint1/tree.c | 5 +++--
3 files changed, 7 insertions(+), 18 deletions(-)
diffs (84 lines):
diff -r 0c8fb56551d4 -r c06f3ae827cd tests/usr.bin/xlint/lint1/msg_230.c
--- a/tests/usr.bin/xlint/lint1/msg_230.c Sat Jun 24 08:11:12 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_230.c Sat Jun 24 17:50:31 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_230.c,v 1.12 2023/02/22 22:30:40 rillig Exp $ */
+/* $NetBSD: msg_230.c,v 1.13 2023/06/24 17:50:31 rillig Exp $ */
# 3 "msg_230.c"
// Test for message: nonportable character comparison '%s' [230]
@@ -113,18 +113,12 @@ compare_greater(char c)
return;
}
+/* Comparing a char expression with a character constant is always valid. */
void
compare_with_character_literal(char ch)
{
- /*
- * FIXME: These comparisons are portable since the character constant
- * is interpreted using the type 'char' on the exact same platform
- * as where the comparison takes place.
- */
- /* expect+1: warning: nonportable character comparison '== -128' [230] */
if (ch == '\200')
return;
- /* expect+1: warning: nonportable character comparison '== -1' [230] */
if (ch == '\377')
return;
if (ch == '\000')
diff -r 0c8fb56551d4 -r c06f3ae827cd tests/usr.bin/xlint/lint1/msg_230_uchar.c
--- a/tests/usr.bin/xlint/lint1/msg_230_uchar.c Sat Jun 24 08:11:12 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_230_uchar.c Sat Jun 24 17:50:31 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_230_uchar.c,v 1.11 2023/02/27 21:59:14 rillig Exp $ */
+/* $NetBSD: msg_230_uchar.c,v 1.12 2023/06/24 17:50:31 rillig Exp $ */
# 3 "msg_230_uchar.c"
// Test for message: nonportable character comparison '%s' [230]
@@ -117,18 +117,12 @@ compare_greater(char c)
return;
}
+/* Comparing a char expression with a character constant is always valid. */
void
compare_with_character_literal(char ch)
{
- /*
- * FIXME: These comparisons are portable since the character constant
- * is interpreted using the type 'char' on the exact same platform
- * as where the comparison takes place.
- */
- /* expect+1: warning: nonportable character comparison '== 128' [230] */
if (ch == '\200')
return;
- /* expect+1: warning: nonportable character comparison '== 255' [230] */
if (ch == '\377')
return;
if (ch == '\000')
diff -r 0c8fb56551d4 -r c06f3ae827cd usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sat Jun 24 08:11:12 2023 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sat Jun 24 17:50:31 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.529 2023/06/24 08:11:12 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.530 2023/06/24 17:50:31 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.529 2023/06/24 08:11:12 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.530 2023/06/24 17:50:31 rillig Exp $");
#endif
#include <float.h>
@@ -580,6 +580,7 @@ static bool
is_out_of_char_range(const tnode_t *tn)
{
return tn->tn_op == CON &&
+ !tn->tn_val->v_char_constant &&
!(0 <= tn->tn_val->v_quad &&
tn->tn_val->v_quad < 1 << (CHAR_SIZE - 1));
}
Home |
Main Index |
Thread Index |
Old Index