Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/common lint: fix wrong warning about out-of-ra...



details:   https://anonhg.NetBSD.org/src/rev/bfb8f1b6dd34
branches:  trunk
changeset: 379982:bfb8f1b6dd34
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jun 29 21:33:08 2021 +0000

description:
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.

diffstat:

 distrib/sets/lists/tests/mi                  |   6 +++---
 tests/usr.bin/xlint/lint1/Makefile           |   3 +--
 tests/usr.bin/xlint/lint1/lex_char_uchar.c   |  12 +++++++-----
 tests/usr.bin/xlint/lint1/lex_char_uchar.exp |   1 -
 usr.bin/xlint/common/inittyp.c               |   7 ++++---
 5 files changed, 15 insertions(+), 14 deletions(-)

diffs (102 lines):

diff -r 4898abaaeceb -r bfb8f1b6dd34 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Tue Jun 29 21:19:58 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Tue Jun 29 21:33:08 2021 +0000
@@ -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 -r 4898abaaeceb -r bfb8f1b6dd34 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Tue Jun 29 21:19:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Tue Jun 29 21:33:08 2021 +0000
@@ -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 -r 4898abaaeceb -r bfb8f1b6dd34 tests/usr.bin/xlint/lint1/lex_char_uchar.c
--- a/tests/usr.bin/xlint/lint1/lex_char_uchar.c        Tue Jun 29 21:19:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/lex_char_uchar.c        Tue Jun 29 21:33:08 2021 +0000
@@ -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 -r 4898abaaeceb -r bfb8f1b6dd34 tests/usr.bin/xlint/lint1/lex_char_uchar.exp
--- a/tests/usr.bin/xlint/lint1/lex_char_uchar.exp      Tue Jun 29 21:19:58 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-lex_char_uchar.c(17): warning: conversion of 'int' to 'char' is out of range [119]
diff -r 4898abaaeceb -r bfb8f1b6dd34 usr.bin/xlint/common/inittyp.c
--- a/usr.bin/xlint/common/inittyp.c    Tue Jun 29 21:19:58 2021 +0000
+++ b/usr.bin/xlint/common/inittyp.c    Tue Jun 29 21:33:08 2021 +0000
@@ -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,



Home | Main Index | Thread Index | Old Index