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: fix wrong integer overflow warning...



details:   https://anonhg.NetBSD.org/src/rev/a8108a0ef2f7
branches:  trunk
changeset: 1023026:a8108a0ef2f7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Aug 19 20:48:47 2021 +0000

description:
lint: fix wrong integer overflow warning for unsigned types

diffstat:

 tests/usr.bin/xlint/lint1/expr_fold.c   |  6 +++---
 tests/usr.bin/xlint/lint1/expr_fold.exp |  2 --
 usr.bin/xlint/lint1/tree.c              |  6 +++---
 3 files changed, 6 insertions(+), 8 deletions(-)

diffs (60 lines):

diff -r 231aa191c5f1 -r a8108a0ef2f7 tests/usr.bin/xlint/lint1/expr_fold.c
--- a/tests/usr.bin/xlint/lint1/expr_fold.c     Thu Aug 19 20:43:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/expr_fold.c     Thu Aug 19 20:48:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expr_fold.c,v 1.1 2021/08/19 20:32:33 rillig Exp $     */
+/*     $NetBSD: expr_fold.c,v 1.2 2021/08/19 20:48:47 rillig Exp $     */
 # 3 "expr_fold.c"
 
 /*
@@ -175,9 +175,9 @@
         * other operand is converted to unsigned as well.
         * See C99 6.3.1.8p1, paragraph 8 of 10.
         */
-       /*FIXME*//* expect+1: warning: integer overflow detected, op + [141] */
+       /* wrong integer overflow warning before tree.c 1.338 from 2021-08-19 */
        take_uint(2147483647 + 1U);
-       /*FIXME*//* expect+1: warning: integer overflow detected, op + [141] */
+       /* wrong integer overflow warning before tree.c 1.338 from 2021-08-19 */
        take_uint(2147483647U + 1);
 }
 
diff -r 231aa191c5f1 -r a8108a0ef2f7 tests/usr.bin/xlint/lint1/expr_fold.exp
--- a/tests/usr.bin/xlint/lint1/expr_fold.exp   Thu Aug 19 20:43:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/expr_fold.exp   Thu Aug 19 20:48:47 2021 +0000
@@ -43,8 +43,6 @@
 expr_fold.c(158): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
 expr_fold.c(165): warning: integer overflow detected, op + [141]
 expr_fold.c(171): warning: integer overflow detected, op + [141]
-expr_fold.c(179): warning: integer overflow detected, op + [141]
-expr_fold.c(181): warning: integer overflow detected, op + [141]
 expr_fold.c(188): warning: integer overflow detected, op - [141]
 expr_fold.c(192): warning: integer overflow detected, op - [141]
 expr_fold.c(195): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
diff -r 231aa191c5f1 -r a8108a0ef2f7 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Thu Aug 19 20:43:58 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Thu Aug 19 20:48:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.337 2021/08/16 18:51:03 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.338 2021/08/19 20:48:47 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.337 2021/08/16 18:51:03 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.338 2021/08/19 20:48:47 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -3072,7 +3072,7 @@
                        if (msb(q, t, -1) == 0)
                                ovfl = true;
                } else if (msb(sl, t, -1) == 0 && msb(sr, t, -1) == 0) {
-                       if (msb(q, t, -1) != 0)
+                       if (msb(q, t, -1) != 0 && !utyp)
                                ovfl = true;
                }
                break;



Home | Main Index | Thread Index | Old Index