Module Name: src
Committed By: rillig
Date: Tue Jun 29 21:33:09 UTC 2021
Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile lex_char_uchar.c
src/usr.bin/xlint/common: inittyp.c
Removed Files:
src/tests/usr.bin/xlint/lint1: lex_char_uchar.exp
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.1069 -r1.1070 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.71 -r1.72 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/lex_char_uchar.c
cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/xlint/lint1/lex_char_uchar.exp
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/common/inittyp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1069 src/distrib/sets/lists/tests/mi:1.1070
--- src/distrib/sets/lists/tests/mi:1.1069 Tue Jun 29 13:58:13 2021
+++ src/distrib/sets/lists/tests/mi Tue Jun 29 21:33:08 2021
@@ -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
Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.71 src/tests/usr.bin/xlint/lint1/Makefile:1.72
--- src/tests/usr.bin/xlint/lint1/Makefile:1.71 Tue Jun 29 13:58:13 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile Tue Jun 29 21:33:09 2021
@@ -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
Index: src/tests/usr.bin/xlint/lint1/lex_char_uchar.c
diff -u src/tests/usr.bin/xlint/lint1/lex_char_uchar.c:1.2 src/tests/usr.bin/xlint/lint1/lex_char_uchar.c:1.3
--- src/tests/usr.bin/xlint/lint1/lex_char_uchar.c:1.2 Tue Jun 29 14:19:51 2021
+++ src/tests/usr.bin/xlint/lint1/lex_char_uchar.c Tue Jun 29 21:33:09 2021
@@ -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';
Index: src/usr.bin/xlint/common/inittyp.c
diff -u src/usr.bin/xlint/common/inittyp.c:1.22 src/usr.bin/xlint/common/inittyp.c:1.23
--- src/usr.bin/xlint/common/inittyp.c:1.22 Sat Mar 27 11:08:00 2021
+++ src/usr.bin/xlint/common/inittyp.c Tue Jun 29 21:33:09 2021
@@ -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,