Sun Jul 4 20:22:31 2021 UTC ()
test/lint: demonstrate wrong warnings for 128-bit shifts


(rillig)
diff -r1.1075 -r1.1076 src/distrib/sets/lists/tests/mi
diff -r1.78 -r1.79 src/tests/usr.bin/xlint/lint1/Makefile
diff -r0 -r1.1 src/tests/usr.bin/xlint/lint1/op_shl_lp64.c
diff -r0 -r1.1 src/tests/usr.bin/xlint/lint1/op_shl_lp64.exp

cvs diff -r1.1075 -r1.1076 src/distrib/sets/lists/tests/mi (expand / switch to unified diff)

--- src/distrib/sets/lists/tests/mi 2021/07/04 13:14:53 1.1075
+++ src/distrib/sets/lists/tests/mi 2021/07/04 20:22:31 1.1076
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.1075 2021/07/04 13:14:53 rillig Exp $ 1# $NetBSD: mi,v 1.1076 2021/07/04 20:22:31 rillig Exp $
2# 2#
3# Note: don't delete entries from here - mark them as "obsolete" instead. 3# Note: don't delete entries from here - mark them as "obsolete" instead.
4# 4#
5./etc/mtree/set.tests tests-sys-root 5./etc/mtree/set.tests tests-sys-root
6./usr/libdata/debug/usr/tests tests-base-debug compattestdir 6./usr/libdata/debug/usr/tests tests-base-debug compattestdir
7./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf 7./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf
8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf 8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf
9./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf 9./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf
10./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf 10./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf
11./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf 11./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf
12./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete 12./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete
13./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete 13./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete
14./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete 14./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete
@@ -6931,26 +6931,28 @@ @@ -6931,26 +6931,28 @@
6931./usr/tests/usr.bin/xlint/lint1/msg_340.exp tests-usr.bin-tests compattestfile,atf 6931./usr/tests/usr.bin/xlint/lint1/msg_340.exp tests-usr.bin-tests compattestfile,atf
6932./usr/tests/usr.bin/xlint/lint1/msg_341.c tests-usr.bin-tests compattestfile,atf 6932./usr/tests/usr.bin/xlint/lint1/msg_341.c tests-usr.bin-tests compattestfile,atf
6933./usr/tests/usr.bin/xlint/lint1/msg_341.exp tests-usr.bin-tests compattestfile,atf 6933./usr/tests/usr.bin/xlint/lint1/msg_341.exp tests-usr.bin-tests compattestfile,atf
6934./usr/tests/usr.bin/xlint/lint1/msg_342.c tests-usr.bin-tests compattestfile,atf 6934./usr/tests/usr.bin/xlint/lint1/msg_342.c tests-usr.bin-tests compattestfile,atf
6935./usr/tests/usr.bin/xlint/lint1/msg_342.exp tests-usr.bin-tests compattestfile,atf 6935./usr/tests/usr.bin/xlint/lint1/msg_342.exp tests-usr.bin-tests compattestfile,atf
6936./usr/tests/usr.bin/xlint/lint1/msg_343.c tests-usr.bin-tests compattestfile,atf 6936./usr/tests/usr.bin/xlint/lint1/msg_343.c tests-usr.bin-tests compattestfile,atf
6937./usr/tests/usr.bin/xlint/lint1/msg_343.exp tests-usr.bin-tests compattestfile,atf 6937./usr/tests/usr.bin/xlint/lint1/msg_343.exp tests-usr.bin-tests compattestfile,atf
6938./usr/tests/usr.bin/xlint/lint1/msg_344.c tests-usr.bin-tests compattestfile,atf 6938./usr/tests/usr.bin/xlint/lint1/msg_344.c tests-usr.bin-tests compattestfile,atf
6939./usr/tests/usr.bin/xlint/lint1/msg_344.exp tests-usr.bin-tests compattestfile,atf 6939./usr/tests/usr.bin/xlint/lint1/msg_344.exp tests-usr.bin-tests compattestfile,atf
6940./usr/tests/usr.bin/xlint/lint1/msg_345.c tests-usr.bin-tests compattestfile,atf 6940./usr/tests/usr.bin/xlint/lint1/msg_345.c tests-usr.bin-tests compattestfile,atf
6941./usr/tests/usr.bin/xlint/lint1/msg_345.exp tests-usr.bin-tests compattestfile,atf 6941./usr/tests/usr.bin/xlint/lint1/msg_345.exp tests-usr.bin-tests compattestfile,atf
6942./usr/tests/usr.bin/xlint/lint1/op_colon.c tests-usr.bin-tests compattestfile,atf 6942./usr/tests/usr.bin/xlint/lint1/op_colon.c tests-usr.bin-tests compattestfile,atf
6943./usr/tests/usr.bin/xlint/lint1/op_colon.exp tests-usr.bin-tests compattestfile,atf 6943./usr/tests/usr.bin/xlint/lint1/op_colon.exp tests-usr.bin-tests compattestfile,atf
 6944./usr/tests/usr.bin/xlint/lint1/op_shl_lp64.c tests-usr.bin-tests compattestfile,atf
 6945./usr/tests/usr.bin/xlint/lint1/op_shl_lp64.exp tests-usr.bin-tests compattestfile,atf
6944./usr/tests/usr.bin/xlint/lint1/stmt_for.c tests-usr.bin-tests compattestfile,atf 6946./usr/tests/usr.bin/xlint/lint1/stmt_for.c tests-usr.bin-tests compattestfile,atf
6945./usr/tests/usr.bin/xlint/lint1/stmt_for.exp tests-usr.bin-tests compattestfile,atf 6947./usr/tests/usr.bin/xlint/lint1/stmt_for.exp tests-usr.bin-tests compattestfile,atf
6946./usr/tests/usr.bin/xlint/lint1/t_integration tests-usr.bin-tests compattestfile,atf 6948./usr/tests/usr.bin/xlint/lint1/t_integration tests-usr.bin-tests compattestfile,atf
6947./usr/tests/usr.bin/ztest tests-usr.bin-tests compattestfile,atf 6949./usr/tests/usr.bin/ztest tests-usr.bin-tests compattestfile,atf
6948./usr/tests/usr.bin/ztest/Atffile tests-usr.bin-tests compattestfile,atf 6950./usr/tests/usr.bin/ztest/Atffile tests-usr.bin-tests compattestfile,atf
6949./usr/tests/usr.bin/ztest/Kyuafile tests-usr.bin-tests compattestfile,atf,kyua 6951./usr/tests/usr.bin/ztest/Kyuafile tests-usr.bin-tests compattestfile,atf,kyua
6950./usr/tests/usr.bin/ztest/t_ztest tests-usr.bin-tests compattestfile,atf 6952./usr/tests/usr.bin/ztest/t_ztest tests-usr.bin-tests compattestfile,atf
6951./usr/tests/usr.sbin tests-usr.sbin-tests compattestfile,atf 6953./usr/tests/usr.sbin tests-usr.sbin-tests compattestfile,atf
6952./usr/tests/usr.sbin/Atffile tests-usr.sbin-tests compattestfile,atf 6954./usr/tests/usr.sbin/Atffile tests-usr.sbin-tests compattestfile,atf
6953./usr/tests/usr.sbin/Kyuafile tests-usr.sbin-tests compattestfile,atf,kyua 6955./usr/tests/usr.sbin/Kyuafile tests-usr.sbin-tests compattestfile,atf,kyua
6954./usr/tests/usr.sbin/cpuctl tests-usr.sbin-tests compattestfile,atf 6956./usr/tests/usr.sbin/cpuctl tests-usr.sbin-tests compattestfile,atf
6955./usr/tests/usr.sbin/cpuctl/Atffile tests-usr.sbin-tests compattestfile,atf 6957./usr/tests/usr.sbin/cpuctl/Atffile tests-usr.sbin-tests compattestfile,atf
6956./usr/tests/usr.sbin/cpuctl/Kyuafile tests-usr.sbin-tests compattestfile,atf,kyua 6958./usr/tests/usr.sbin/cpuctl/Kyuafile tests-usr.sbin-tests compattestfile,atf,kyua

cvs diff -r1.78 -r1.79 src/tests/usr.bin/xlint/lint1/Makefile (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Makefile 2021/07/04 13:14:54 1.78
+++ src/tests/usr.bin/xlint/lint1/Makefile 2021/07/04 20:22:31 1.79
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.78 2021/07/04 13:14:54 rillig Exp $ 1# $NetBSD: Makefile,v 1.79 2021/07/04 20:22:31 rillig Exp $
2 2
3NOMAN= # defined 3NOMAN= # defined
4MAX_MESSAGE= 345 # see lint1/err.c 4MAX_MESSAGE= 345 # see lint1/err.c
5 5
6.include <bsd.own.mk> 6.include <bsd.own.mk>
7 7
8TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1 8TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1
9 9
10TESTS_SH= t_integration 10TESTS_SH= t_integration
11 11
12FILESDIR= ${TESTSDIR} 12FILESDIR= ${TESTSDIR}
13FILES+= c11_generic_expression.c 13FILES+= c11_generic_expression.c
14FILES+= c11_generic_expression.exp 14FILES+= c11_generic_expression.exp
@@ -141,26 +141,28 @@ FILES+= lex_integer_ilp32.exp @@ -141,26 +141,28 @@ FILES+= lex_integer_ilp32.exp
141FILES+= lex_string.c 141FILES+= lex_string.c
142FILES+= lex_string.exp 142FILES+= lex_string.exp
143FILES+= lex_wide_char.c 143FILES+= lex_wide_char.c
144FILES+= lex_wide_char.exp 144FILES+= lex_wide_char.exp
145FILES+= lex_wide_string.c 145FILES+= lex_wide_string.c
146FILES+= lex_wide_string.exp 146FILES+= lex_wide_string.exp
147FILES+= ${:U0 ${:U:${:Urange=${MAX_MESSAGE}}}:C,^.$,0&,:C,^..$,0&,:@i@msg_${i}.c msg_${i}.exp@:Nmsg_176.exp} 147FILES+= ${:U0 ${:U:${:Urange=${MAX_MESSAGE}}}:C,^.$,0&,:C,^..$,0&,:@i@msg_${i}.c msg_${i}.exp@:Nmsg_176.exp}
148FILES+= msg_230_uchar.c 148FILES+= msg_230_uchar.c
149FILES+= msg_230_uchar.exp 149FILES+= msg_230_uchar.exp
150FILES+= msg_259_ilp32.c 150FILES+= msg_259_ilp32.c
151FILES+= msg_259_ilp32.exp 151FILES+= msg_259_ilp32.exp
152FILES+= op_colon.c 152FILES+= op_colon.c
153FILES+= op_colon.exp 153FILES+= op_colon.exp
 154FILES+= op_shl_lp64.c
 155FILES+= op_shl_lp64.exp
154FILES+= stmt_for.c 156FILES+= stmt_for.c
155FILES+= stmt_for.exp 157FILES+= stmt_for.exp
156 158
157# Note: only works for adding tests. 159# Note: only works for adding tests.
158# To remove a test, the $$mi file must be edited manually. 160# To remove a test, the $$mi file must be edited manually.
159sync-mi: .PHONY 161sync-mi: .PHONY
160 @set -eu; \ 162 @set -eu; \
161 cd "${MAKEFILE:tA:H}/../../../.."; \ 163 cd "${MAKEFILE:tA:H}/../../../.."; \
162 mi="distrib/sets/lists/tests/mi"; \ 164 mi="distrib/sets/lists/tests/mi"; \
163 cvs update "$$mi"; \ 165 cvs update "$$mi"; \
164 fmt="./usr/tests/usr.bin/xlint/lint1/%s\ttests-usr.bin-tests\tcompattestfile,atf\n"; \ 166 fmt="./usr/tests/usr.bin/xlint/lint1/%s\ttests-usr.bin-tests\tcompattestfile,atf\n"; \
165 cat "$$mi" > "$$mi.tmp"; \ 167 cat "$$mi" > "$$mi.tmp"; \
166 printf "$$fmt" ${FILES} >> "$$mi.tmp"; \ 168 printf "$$fmt" ${FILES} >> "$$mi.tmp"; \

File Added: src/tests/usr.bin/xlint/lint1/op_shl_lp64.c
/*	$NetBSD: op_shl_lp64.c,v 1.1 2021/07/04 20:22:31 rillig Exp $	*/
# 3 "op_shl_lp64.c"

/*
 * Test overflow on shl of 128-bit integers, as seen in
 * ecp_nistp256.c(296).
 */

/* lint1-only-if lp64 */

const __uint128_t zero105 =
    /* FIXME: 105 is ok for __uint128_t */
    /* expect+1: warning: shift amount 105 is greater than bit-size 32 of 'int' [122] */
    (((__uint128_t)1) << 105)
    /* FIXME: 41 is ok for __uint128_t */
    /* expect+1: warning: shift amount 41 is greater than bit-size 32 of 'int' [122] */
    - (((__uint128_t)1) << 41)
    - (((__uint128_t)1) << 9);

File Added: src/tests/usr.bin/xlint/lint1/Attic/op_shl_lp64.exp
op_shl_lp64.c(14): warning: shift amount 105 is greater than bit-size 32 of 'int' [122]
op_shl_lp64.c(17): warning: shift amount 41 is greater than bit-size 32 of 'int' [122]