Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src tests/lint: merge tests for '>>'
details: https://anonhg.NetBSD.org/src/rev/c93b5f3146ec
branches: trunk
changeset: 373283:c93b5f3146ec
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jan 29 17:02:09 2023 +0000
description:
tests/lint: merge tests for '>>'
diffstat:
distrib/sets/lists/tests/mi | 4 +-
tests/usr.bin/xlint/lint1/Makefile | 3 +-
tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c | 28 --------------------
tests/usr.bin/xlint/lint1/msg_117.c | 10 +++++-
tests/usr.bin/xlint/lint1/msg_132.c | 19 ++++++++++++-
5 files changed, 29 insertions(+), 35 deletions(-)
diffs (129 lines):
diff -r be1a35374f4f -r c93b5f3146ec distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Jan 29 17:00:12 2023 +0000
+++ b/distrib/sets/lists/tests/mi Sun Jan 29 17:02:09 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1248 2023/01/23 23:01:52 sjg Exp $
+# $NetBSD: mi,v 1.1249 2023/01/29 17:02:09 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6508,7 +6508,7 @@
./usr/tests/usr.bin/xlint/lint1/d_pr_22119.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_return_type.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_return_type.exp tests-obsolete obsolete,atf
-./usr/tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/d_type_conv1.c tests-usr.bin-tests compattestfile,atf
diff -r be1a35374f4f -r c93b5f3146ec tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Sun Jan 29 17:00:12 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Sun Jan 29 17:02:09 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.134 2023/01/22 17:17:25 rillig Exp $
+# $NetBSD: Makefile,v 1.135 2023/01/29 17:02:09 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 350 # see lint1/err.c
@@ -81,7 +81,6 @@
FILES+= d_packed_structs.c
FILES+= d_pr_22119.c
FILES+= d_return_type.c
-FILES+= d_shift_to_narrower_type.c
FILES+= d_struct_init_nested.c
FILES+= d_type_conv1.c
FILES+= d_type_conv2.c
diff -r be1a35374f4f -r c93b5f3146ec tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c
--- a/tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c Sun Jan 29 17:00:12 2023 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/* $NetBSD: d_shift_to_narrower_type.c,v 1.3 2021/01/31 14:57:28 rillig Exp $ */
-# 3 "d_shift_to_narrower_type.c"
-
-// Test that type shifts that result to narrower types don't produce warnings.
-
-void
-foo(void)
-{
- unsigned long l = 100;
- unsigned long long ll = 100;
- unsigned int i = 100;
- unsigned short s = 100;
- unsigned char c = 1;
-
- l = ll >> 32;
-// i = ll >> 31;
- i = ll >> 32;
- s = ll >> 48;
- c = ll >> 56;
- s = i >> 16;
- c = i >> 24;
- c = s >> 8;
- (void)≪
- (void)&l;
- (void)&i;
- (void)&s;
- (void)&c;
-}
diff -r be1a35374f4f -r c93b5f3146ec tests/usr.bin/xlint/lint1/msg_117.c
--- a/tests/usr.bin/xlint/lint1/msg_117.c Sun Jan 29 17:00:12 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_117.c Sun Jan 29 17:02:09 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_117.c,v 1.11 2022/06/16 16:58:36 rillig Exp $ */
+/* $NetBSD: msg_117.c,v 1.12 2023/01/29 17:02:09 rillig Exp $ */
# 3 "msg_117.c"
// Test for message: bitwise '%s' on signed value possibly nonportable [117]
@@ -86,7 +86,7 @@
*
* K&R provides more guarantees by saying: Right shifting a signed quantity
* will fill with sign bits ("arithmetic shift") on some machines such as the
- * PDP-Il, and with 0-bits ("logical shift") on others.
+ * PDP-11, and with 0-bits ("logical shift") on others.
*
* https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html says:
* Signed '>>' acts on negative numbers by sign extension.
@@ -138,4 +138,10 @@
/* expect+1: warning: bitwise '>>' on signed value possibly nonportable [117] */
if (((x >> 31) & 2) != 0)
return;
+
+ /* The result of '&' is guaranteed to be positive. */
+ /* XXX: Don't warn here. */
+ /* expect+1: warning: bitwise '>>' on signed value possibly nonportable [117] */
+ if ((x & 0xf0) >> 4 != 0)
+ return;
}
diff -r be1a35374f4f -r c93b5f3146ec tests/usr.bin/xlint/lint1/msg_132.c
--- a/tests/usr.bin/xlint/lint1/msg_132.c Sun Jan 29 17:00:12 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_132.c Sun Jan 29 17:02:09 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_132.c,v 1.24 2022/07/07 18:11:29 rillig Exp $ */
+/* $NetBSD: msg_132.c,v 1.25 2023/01/29 17:02:09 rillig Exp $ */
# 3 "msg_132.c"
// Test for message: conversion from '%s' to '%s' may lose accuracy [132]
@@ -237,6 +237,23 @@
if (x > 2)
/* expect+1: warning: conversion from 'unsigned long long' to 'unsigned int' may lose accuracy [132] */
return x >> 31;
+
+ /* expect+1: warning: conversion from 'unsigned long long' to 'unsigned int' may lose accuracy [132] */
+ u32 = u64 >> 31;
+ u32 = u64 >> 32;
+ u16 = u64 >> 48;
+ u8 = u64 >> 56;
+ u16 = u32 >> 16;
+ u8 = u32 >> 24;
+ u8 = u16 >> 8;
+
+ /*
+ * No matter whether the big integer is signed or unsigned, the
+ * result of '&' is guaranteed to be an unsigned value.
+ */
+ u8 = (s64 & 0xf0) >> 4;
+ u8 = (s8 & 0xf0) >> 4;
+
/* expect+1: warning: conversion from 'unsigned long long' to 'unsigned int' may lose accuracy [132] */
return x;
}
Home |
Main Index |
Thread Index |
Old Index