Module Name: src Committed By: rillig Date: Sun Jan 29 17:02:09 UTC 2023
Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/xlint/lint1: Makefile msg_117.c msg_132.c Removed Files: src/tests/usr.bin/xlint/lint1: d_shift_to_narrower_type.c Log Message: tests/lint: merge tests for '>>' To generate a diff of this commit: cvs rdiff -u -r1.1248 -r1.1249 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.134 -r1.135 src/tests/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r1.3 -r0 \ src/tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/msg_117.c cvs rdiff -u -r1.24 -r1.25 src/tests/usr.bin/xlint/lint1/msg_132.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1248 src/distrib/sets/lists/tests/mi:1.1249 --- src/distrib/sets/lists/tests/mi:1.1248 Mon Jan 23 23:01:52 2023 +++ src/distrib/sets/lists/tests/mi Sun Jan 29 17:02:09 2023 @@ -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 Index: src/tests/usr.bin/xlint/lint1/Makefile diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.134 src/tests/usr.bin/xlint/lint1/Makefile:1.135 --- src/tests/usr.bin/xlint/lint1/Makefile:1.134 Sun Jan 22 17:17:25 2023 +++ src/tests/usr.bin/xlint/lint1/Makefile Sun Jan 29 17:02:09 2023 @@ -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_nolimit_init.c 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 Index: src/tests/usr.bin/xlint/lint1/msg_117.c diff -u src/tests/usr.bin/xlint/lint1/msg_117.c:1.11 src/tests/usr.bin/xlint/lint1/msg_117.c:1.12 --- src/tests/usr.bin/xlint/lint1/msg_117.c:1.11 Thu Jun 16 16:58:36 2022 +++ src/tests/usr.bin/xlint/lint1/msg_117.c Sun Jan 29 17:02:09 2023 @@ -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 @@ shr_unsigned_char_promoted_unsigned(unsi * * 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 @@ shr_signed_ignoring_high_bits(int x) /* 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; } Index: src/tests/usr.bin/xlint/lint1/msg_132.c diff -u src/tests/usr.bin/xlint/lint1/msg_132.c:1.24 src/tests/usr.bin/xlint/lint1/msg_132.c:1.25 --- src/tests/usr.bin/xlint/lint1/msg_132.c:1.24 Thu Jul 7 18:11:29 2022 +++ src/tests/usr.bin/xlint/lint1/msg_132.c Sun Jan 29 17:02:09 2023 @@ -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 @@ test_ic_shr(u64_t x) 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; }