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: add details to warning about too l...



details:   https://anonhg.NetBSD.org/src/rev/c587237ec675
branches:  trunk
changeset: 961036:c587237ec675
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Apr 06 21:32:57 2021 +0000

description:
lint: add details to warning about too large shift amount

The previous message 'shift greater than size of object' was too short
to give reasonable hints, especially when the expressions involve
typedefs or macros.

diffstat:

 tests/usr.bin/xlint/lint1/msg_117.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_120.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_122.c   |   4 ++--
 tests/usr.bin/xlint/lint1/msg_122.exp |   2 +-
 usr.bin/xlint/lint1/err.c             |   6 +++---
 usr.bin/xlint/lint1/tree.c            |  10 ++++++----
 6 files changed, 14 insertions(+), 12 deletions(-)

diffs (99 lines):

diff -r b3281e4c3084 -r c587237ec675 tests/usr.bin/xlint/lint1/msg_117.exp
--- a/tests/usr.bin/xlint/lint1/msg_117.exp     Tue Apr 06 21:17:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_117.exp     Tue Apr 06 21:32:57 2021 +0000
@@ -1,6 +1,6 @@
 msg_117.c(11): warning: bitwise '>>' on signed value possibly nonportable [117]
 msg_117.c(23): warning: bitwise '>>' on signed value nonportable [120]
 msg_117.c(29): warning: bitwise '>>' on signed value possibly nonportable [117]
-msg_117.c(29): warning: shift greater than size of object [122]
+msg_117.c(29): warning: shift amount 4660 is greater than bit-size 32 of 'int' [122]
 msg_117.c(35): warning: bitwise '>>' on signed value possibly nonportable [117]
 msg_117.c(35): warning: negative shift [121]
diff -r b3281e4c3084 -r c587237ec675 tests/usr.bin/xlint/lint1/msg_120.exp
--- a/tests/usr.bin/xlint/lint1/msg_120.exp     Tue Apr 06 21:17:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_120.exp     Tue Apr 06 21:32:57 2021 +0000
@@ -1,6 +1,6 @@
 msg_120.c(11): warning: bitwise '>>' on signed value possibly nonportable [117]
 msg_120.c(23): warning: bitwise '>>' on signed value nonportable [120]
 msg_120.c(29): warning: bitwise '>>' on signed value possibly nonportable [117]
-msg_120.c(29): warning: shift greater than size of object [122]
+msg_120.c(29): warning: shift amount 4660 is greater than bit-size 32 of 'int' [122]
 msg_120.c(35): warning: bitwise '>>' on signed value possibly nonportable [117]
 msg_120.c(35): warning: negative shift [121]
diff -r b3281e4c3084 -r c587237ec675 tests/usr.bin/xlint/lint1/msg_122.c
--- a/tests/usr.bin/xlint/lint1/msg_122.c       Tue Apr 06 21:17:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_122.c       Tue Apr 06 21:32:57 2021 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_122.c,v 1.3 2021/01/31 11:12:07 rillig Exp $       */
+/*     $NetBSD: msg_122.c,v 1.4 2021/04/06 21:32:57 rillig Exp $       */
 # 3 "msg_122.c"
 
-// Test for message: shift greater than size of object [122]
+// Test for message: shift amount %llu is greater than bit-size %llu of '%s' [122]
 
 int
 example(int x)
diff -r b3281e4c3084 -r c587237ec675 tests/usr.bin/xlint/lint1/msg_122.exp
--- a/tests/usr.bin/xlint/lint1/msg_122.exp     Tue Apr 06 21:17:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_122.exp     Tue Apr 06 21:32:57 2021 +0000
@@ -1,1 +1,1 @@
-msg_122.c(9): warning: shift greater than size of object [122]
+msg_122.c(9): warning: shift amount 129 is greater than bit-size 32 of 'int' [122]
diff -r b3281e4c3084 -r c587237ec675 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Tue Apr 06 21:17:27 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Tue Apr 06 21:32:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.102 2021/04/05 02:05:47 rillig Exp $ */
+/*     $NetBSD: err.c,v 1.103 2021/04/06 21:32:57 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.102 2021/04/05 02:05:47 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.103 2021/04/06 21:32:57 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -176,7 +176,7 @@
        "conversion of '%s' to '%s' is out of range",                 /* 119 */
        "bitwise '%s' on signed value nonportable",                   /* 120 */
        "negative shift",                                             /* 121 */
-       "shift greater than size of object",                          /* 122 */
+       "shift amount %llu is greater than bit-size %llu of '%s'",    /* 122 */
        "illegal combination of %s (%s) and %s (%s), op %s",          /* 123 */
        "illegal pointer combination (%s) and (%s), op %s",           /* 124 */
        "ANSI C forbids ordered comparisons of pointers to functions",/* 125 */
diff -r b3281e4c3084 -r c587237ec675 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Tue Apr 06 21:17:27 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Tue Apr 06 21:32:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.268 2021/04/06 21:17:27 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.269 2021/04/06 21:32:57 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.268 2021/04/06 21:17:27 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.269 2021/04/06 21:32:57 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -910,8 +910,10 @@
                        warning(267);
                } else if ((uint64_t)rn->tn_val->v_quad >
                           (uint64_t)size_in_bits(lt)) {
-                       /* shift greater than size of object */
-                       warning(122);
+                       /* shift amount %llu is greater than bit-size %llu of '%s' */
+                       warning(122, (unsigned long long)rn->tn_val->v_quad,
+                           (unsigned long long)size_in_bits(lt),
+                           tspec_name(lt));
                }
        }
 }



Home | Main Index | Thread Index | Old Index