Module Name: src
Committed By: rillig
Date: Tue Apr 6 21:32:57 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_117.exp msg_120.exp msg_122.c
msg_122.exp
src/usr.bin/xlint/lint1: err.c tree.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_117.exp \
src/tests/usr.bin/xlint/lint1/msg_120.exp \
src/tests/usr.bin/xlint/lint1/msg_122.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_122.exp
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.268 -r1.269 src/usr.bin/xlint/lint1/tree.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/msg_117.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_117.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_117.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_117.exp:1.3 Sun Jan 31 11:44:48 2021
+++ src/tests/usr.bin/xlint/lint1/msg_117.exp Tue Apr 6 21:32:57 2021
@@ -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]
Index: src/tests/usr.bin/xlint/lint1/msg_120.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_120.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_120.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_120.exp:1.3 Sun Jan 31 11:44:48 2021
+++ src/tests/usr.bin/xlint/lint1/msg_120.exp Tue Apr 6 21:32:57 2021
@@ -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]
Index: src/tests/usr.bin/xlint/lint1/msg_122.c
diff -u src/tests/usr.bin/xlint/lint1/msg_122.c:1.3 src/tests/usr.bin/xlint/lint1/msg_122.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_122.c:1.3 Sun Jan 31 11:12:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_122.c Tue Apr 6 21:32:57 2021
@@ -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)
Index: src/tests/usr.bin/xlint/lint1/msg_122.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_122.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_122.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_122.exp:1.2 Fri Jan 8 21:25:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_122.exp Tue Apr 6 21:32:57 2021
@@ -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]
Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.102 src/usr.bin/xlint/lint1/err.c:1.103
--- src/usr.bin/xlint/lint1/err.c:1.102 Mon Apr 5 02:05:47 2021
+++ src/usr.bin/xlint/lint1/err.c Tue Apr 6 21:32:57 2021
@@ -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 @@ const char *msgs[] = {
"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 */
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.268 src/usr.bin/xlint/lint1/tree.c:1.269
--- src/usr.bin/xlint/lint1/tree.c:1.268 Tue Apr 6 21:17:27 2021
+++ src/usr.bin/xlint/lint1/tree.c Tue Apr 6 21:32:57 2021
@@ -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 @@ typeok_shift(tspec_t lt, const tnode_t *
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));
}
}
}