summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2021-06-29 21:33:08 +0000
committerrillig <rillig@NetBSD.org>2021-06-29 21:33:08 +0000
commit36fce0ea8eeaa2f9d8ebf718b096ee32936a37d7 (patch)
tree388f3ac07448081ad71caf2e7689194f0ab888cc
parent36fb760d0a140bfb015ea08a41c4d461e9091f6f (diff)
lint: fix wrong warning about out-of-range value '\xff' for char
This only affects platforms where char has the same representation as unsigned char.
-rw-r--r--distrib/sets/lists/tests/mi6
-rw-r--r--tests/usr.bin/xlint/lint1/Makefile3
-rw-r--r--tests/usr.bin/xlint/lint1/lex_char_uchar.c12
-rw-r--r--tests/usr.bin/xlint/lint1/lex_char_uchar.exp1
-rw-r--r--usr.bin/xlint/common/inittyp.c7
5 files changed, 15 insertions, 14 deletions
diff --git a/distrib/sets/lists/tests/mi b/distrib/sets/lists/tests/mi
index da8f23671dd..e39738c1d92 100644
--- a/distrib/sets/lists/tests/mi
+++ b/distrib/sets/lists/tests/mi
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1069 2021/06/29 13:58:13 rillig Exp $
+# $NetBSD: mi,v 1.1070 2021/06/29 21:33:08 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6205,7 +6205,7 @@
./usr/tests/usr.bin/xlint/lint1/emit.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/emit.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/emit.exp-ln tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/xlint/lint1/emit.ln obsolete obsolete
+./usr/tests/usr.bin/xlint/lint1/emit.ln tests-obsolete obsolete
./usr/tests/usr.bin/xlint/lint1/expr_range.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/expr_range.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.c tests-usr.bin-tests compattestfile,atf
@@ -6223,7 +6223,7 @@
./usr/tests/usr.bin/xlint/lint1/lex_char.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/lex_char.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/lex_char_uchar.c tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/xlint/lint1/lex_char_uchar.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/lex_char_uchar.exp tests-obsolete obsolete
./usr/tests/usr.bin/xlint/lint1/lex_comment.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/lex_comment.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/lex_floating.c tests-usr.bin-tests compattestfile,atf
diff --git a/tests/usr.bin/xlint/lint1/Makefile b/tests/usr.bin/xlint/lint1/Makefile
index 571ec894790..ec478045eb6 100644
--- a/tests/usr.bin/xlint/lint1/Makefile
+++ b/tests/usr.bin/xlint/lint1/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.71 2021/06/29 13:58:13 rillig Exp $
+# $NetBSD: Makefile,v 1.72 2021/06/29 21:33:09 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 345 # see lint1/err.c
@@ -126,7 +126,6 @@ FILES+= gcc_typeof_after_statement.exp
FILES+= lex_char.c
FILES+= lex_char.exp
FILES+= lex_char_uchar.c
-FILES+= lex_char_uchar.exp
FILES+= lex_comment.c
FILES+= lex_comment.exp
FILES+= lex_floating.c
diff --git a/tests/usr.bin/xlint/lint1/lex_char_uchar.c b/tests/usr.bin/xlint/lint1/lex_char_uchar.c
index 25d0fe1a096..a984ae2c759 100644
--- a/tests/usr.bin/xlint/lint1/lex_char_uchar.c
+++ b/tests/usr.bin/xlint/lint1/lex_char_uchar.c
@@ -1,4 +1,4 @@
-/* $NetBSD: lex_char_uchar.c,v 1.2 2021/06/29 14:19:51 rillig Exp $ */
+/* $NetBSD: lex_char_uchar.c,v 1.3 2021/06/29 21:33:09 rillig Exp $ */
# 3 "lex_char_uchar.c"
/*
@@ -9,9 +9,11 @@
/* lint1-only-if uchar */
/*
- * FIXME: The warning is bogus; it must be possible to initialize a char
- * variable with a character constant.
- * See tree.c, function convert_constant.
+ * Before inittyp.c 1.23 from 2021-06-29, the following initialization
+ * triggered a wrong warning "conversion of 'int' to 'char' is out of range",
+ * but only on platforms where char has the same representation as unsigned
+ * char. There are only few of these platforms, which allowed this bug to
+ * survive for almost 26 years, since the initial commit of lint on
+ * 1995-07-03.
*/
-/* expect+1: conversion of 'int' to 'char' is out of range [119] */
char ch = '\xff';
diff --git a/tests/usr.bin/xlint/lint1/lex_char_uchar.exp b/tests/usr.bin/xlint/lint1/lex_char_uchar.exp
deleted file mode 100644
index e8e2ccfb9c6..00000000000
--- a/tests/usr.bin/xlint/lint1/lex_char_uchar.exp
+++ /dev/null
@@ -1 +0,0 @@
-lex_char_uchar.c(17): warning: conversion of 'int' to 'char' is out of range [119]
diff --git a/usr.bin/xlint/common/inittyp.c b/usr.bin/xlint/common/inittyp.c
index 7ebdbd40474..7ebc9589927 100644
--- a/usr.bin/xlint/common/inittyp.c
+++ b/usr.bin/xlint/common/inittyp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: inittyp.c,v 1.22 2021/03/27 11:08:00 rillig Exp $ */
+/* $NetBSD: inittyp.c,v 1.23 2021/06/29 21:33:09 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: inittyp.c,v 1.22 2021/03/27 11:08:00 rillig Exp $");
+__RCSID("$NetBSD: inittyp.c,v 1.23 2021/06/29 21:33:09 rillig Exp $");
#endif
#include <limits.h>
@@ -77,7 +77,8 @@ inittyp(void)
typeinfo(BOOL, BOOL, BOOL, CHAR_SIZE, 1,
1, 1, 0, 1, 1, 0, "_Bool"),
typeinfo(CHAR, SCHAR, UCHAR, CHAR_SIZE, 8,
- 1, 0, 0, 1, 1, 0, "char"),
+ 1, /*CONSTCOND*/ TARG_CHAR_MIN == 0 ? 1 : 0,
+ /* */ 0, 1, 1, 0, "char"),
typeinfo(SCHAR, SCHAR, UCHAR, CHAR_SIZE, 8,
1, 0, 0, 1, 1, 0, "signed char"),
typeinfo(UCHAR, SCHAR, UCHAR, CHAR_SIZE, 8,