Tue Jul 13 19:38:11 2021 UTC ()
tests/lint: test binary integer literals and underscores


(rillig)
diff -r1.1085 -r1.1086 src/distrib/sets/lists/tests/mi
diff -r1.87 -r1.88 src/tests/usr.bin/xlint/lint1/Makefile
diff -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/lex_integer.c
diff -r0 -r1.1 src/tests/usr.bin/xlint/lint1/lex_integer_binary.c
diff -r0 -r1.1 src/tests/usr.bin/xlint/lint1/lex_integer_binary.exp

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

--- src/distrib/sets/lists/tests/mi 2021/07/11 19:24:41 1.1085
+++ src/distrib/sets/lists/tests/mi 2021/07/13 19:38:10 1.1086
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.1085 2021/07/11 19:24:41 rillig Exp $ 1# $NetBSD: mi,v 1.1086 2021/07/13 19:38:10 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
@@ -6250,26 +6250,28 @@ @@ -6250,26 +6250,28 @@
6250./usr/tests/usr.bin/xlint/lint1/init.exp tests-usr.bin-tests compattestfile,atf 6250./usr/tests/usr.bin/xlint/lint1/init.exp tests-usr.bin-tests compattestfile,atf
6251./usr/tests/usr.bin/xlint/lint1/init_c90.c tests-usr.bin-tests compattestfile,atf 6251./usr/tests/usr.bin/xlint/lint1/init_c90.c tests-usr.bin-tests compattestfile,atf
6252./usr/tests/usr.bin/xlint/lint1/init_c90.exp tests-usr.bin-tests compattestfile,atf 6252./usr/tests/usr.bin/xlint/lint1/init_c90.exp tests-usr.bin-tests compattestfile,atf
6253./usr/tests/usr.bin/xlint/lint1/lex_char.c tests-usr.bin-tests compattestfile,atf 6253./usr/tests/usr.bin/xlint/lint1/lex_char.c tests-usr.bin-tests compattestfile,atf
6254./usr/tests/usr.bin/xlint/lint1/lex_char.exp tests-usr.bin-tests compattestfile,atf 6254./usr/tests/usr.bin/xlint/lint1/lex_char.exp tests-usr.bin-tests compattestfile,atf
6255./usr/tests/usr.bin/xlint/lint1/lex_char_uchar.c tests-usr.bin-tests compattestfile,atf 6255./usr/tests/usr.bin/xlint/lint1/lex_char_uchar.c tests-usr.bin-tests compattestfile,atf
6256./usr/tests/usr.bin/xlint/lint1/lex_char_uchar.exp tests-obsolete obsolete 6256./usr/tests/usr.bin/xlint/lint1/lex_char_uchar.exp tests-obsolete obsolete
6257./usr/tests/usr.bin/xlint/lint1/lex_comment.c tests-usr.bin-tests compattestfile,atf 6257./usr/tests/usr.bin/xlint/lint1/lex_comment.c tests-usr.bin-tests compattestfile,atf
6258./usr/tests/usr.bin/xlint/lint1/lex_comment.exp tests-usr.bin-tests compattestfile,atf 6258./usr/tests/usr.bin/xlint/lint1/lex_comment.exp tests-usr.bin-tests compattestfile,atf
6259./usr/tests/usr.bin/xlint/lint1/lex_floating.c tests-usr.bin-tests compattestfile,atf 6259./usr/tests/usr.bin/xlint/lint1/lex_floating.c tests-usr.bin-tests compattestfile,atf
6260./usr/tests/usr.bin/xlint/lint1/lex_floating.exp tests-usr.bin-tests compattestfile,atf 6260./usr/tests/usr.bin/xlint/lint1/lex_floating.exp tests-usr.bin-tests compattestfile,atf
6261./usr/tests/usr.bin/xlint/lint1/lex_integer.c tests-usr.bin-tests compattestfile,atf 6261./usr/tests/usr.bin/xlint/lint1/lex_integer.c tests-usr.bin-tests compattestfile,atf
6262./usr/tests/usr.bin/xlint/lint1/lex_integer.exp tests-usr.bin-tests compattestfile,atf 6262./usr/tests/usr.bin/xlint/lint1/lex_integer.exp tests-usr.bin-tests compattestfile,atf
 6263./usr/tests/usr.bin/xlint/lint1/lex_integer_binary.c tests-usr.bin-tests compattestfile,atf
 6264./usr/tests/usr.bin/xlint/lint1/lex_integer_binary.exp tests-usr.bin-tests compattestfile,atf
6263./usr/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c tests-usr.bin-tests compattestfile,atf 6265./usr/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c tests-usr.bin-tests compattestfile,atf
6264./usr/tests/usr.bin/xlint/lint1/lex_integer_ilp32.exp tests-usr.bin-tests compattestfile,atf 6266./usr/tests/usr.bin/xlint/lint1/lex_integer_ilp32.exp tests-usr.bin-tests compattestfile,atf
6265./usr/tests/usr.bin/xlint/lint1/lex_string.c tests-usr.bin-tests compattestfile,atf 6267./usr/tests/usr.bin/xlint/lint1/lex_string.c tests-usr.bin-tests compattestfile,atf
6266./usr/tests/usr.bin/xlint/lint1/lex_string.exp tests-usr.bin-tests compattestfile,atf 6268./usr/tests/usr.bin/xlint/lint1/lex_string.exp tests-usr.bin-tests compattestfile,atf
6267./usr/tests/usr.bin/xlint/lint1/lex_wide_char.c tests-usr.bin-tests compattestfile,atf 6269./usr/tests/usr.bin/xlint/lint1/lex_wide_char.c tests-usr.bin-tests compattestfile,atf
6268./usr/tests/usr.bin/xlint/lint1/lex_wide_char.exp tests-usr.bin-tests compattestfile,atf 6270./usr/tests/usr.bin/xlint/lint1/lex_wide_char.exp tests-usr.bin-tests compattestfile,atf
6269./usr/tests/usr.bin/xlint/lint1/lex_wide_string.c tests-usr.bin-tests compattestfile,atf 6271./usr/tests/usr.bin/xlint/lint1/lex_wide_string.c tests-usr.bin-tests compattestfile,atf
6270./usr/tests/usr.bin/xlint/lint1/lex_wide_string.exp tests-usr.bin-tests compattestfile,atf 6272./usr/tests/usr.bin/xlint/lint1/lex_wide_string.exp tests-usr.bin-tests compattestfile,atf
6271./usr/tests/usr.bin/xlint/lint1/msg_000.c tests-usr.bin-tests compattestfile,atf 6273./usr/tests/usr.bin/xlint/lint1/msg_000.c tests-usr.bin-tests compattestfile,atf
6272./usr/tests/usr.bin/xlint/lint1/msg_000.exp tests-usr.bin-tests compattestfile,atf 6274./usr/tests/usr.bin/xlint/lint1/msg_000.exp tests-usr.bin-tests compattestfile,atf
6273./usr/tests/usr.bin/xlint/lint1/msg_000_c90.c tests-usr.bin-tests compattestfile,atf 6275./usr/tests/usr.bin/xlint/lint1/msg_000_c90.c tests-usr.bin-tests compattestfile,atf
6274./usr/tests/usr.bin/xlint/lint1/msg_000_c90.exp tests-usr.bin-tests compattestfile,atf 6276./usr/tests/usr.bin/xlint/lint1/msg_000_c90.exp tests-usr.bin-tests compattestfile,atf
6275./usr/tests/usr.bin/xlint/lint1/msg_001.c tests-usr.bin-tests compattestfile,atf 6277./usr/tests/usr.bin/xlint/lint1/msg_001.c tests-usr.bin-tests compattestfile,atf

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

--- src/tests/usr.bin/xlint/lint1/Makefile 2021/07/13 18:50:16 1.87
+++ src/tests/usr.bin/xlint/lint1/Makefile 2021/07/13 19:38:10 1.88
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.87 2021/07/13 18:50:16 rillig Exp $ 1# $NetBSD: Makefile,v 1.88 2021/07/13 19:38:10 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
8ARCHSUBDIR!= cd ${NETBSDSRCDIR}/usr.bin/xlint/lint1 && ${MAKE} -v ARCHSUBDIR 8ARCHSUBDIR!= cd ${NETBSDSRCDIR}/usr.bin/xlint/lint1 && ${MAKE} -v ARCHSUBDIR
9 9
10TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1 10TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1
11 11
12TESTS_SH= t_integration 12TESTS_SH= t_integration
13TESTS_SH_SRC_t_integration= archsubdir.sh t_integration.sh 13TESTS_SH_SRC_t_integration= archsubdir.sh t_integration.sh
14 14
@@ -151,26 +151,28 @@ FILES+= gcc_typeof_after_statement.exp @@ -151,26 +151,28 @@ FILES+= gcc_typeof_after_statement.exp
151FILES+= init.c 151FILES+= init.c
152FILES+= init.exp 152FILES+= init.exp
153FILES+= init_c90.c 153FILES+= init_c90.c
154FILES+= init_c90.exp 154FILES+= init_c90.exp
155FILES+= lex_char.c 155FILES+= lex_char.c
156FILES+= lex_char.exp 156FILES+= lex_char.exp
157FILES+= lex_char_uchar.c 157FILES+= lex_char_uchar.c
158FILES+= lex_comment.c 158FILES+= lex_comment.c
159FILES+= lex_comment.exp 159FILES+= lex_comment.exp
160FILES+= lex_floating.c 160FILES+= lex_floating.c
161FILES+= lex_floating.exp 161FILES+= lex_floating.exp
162FILES+= lex_integer.c 162FILES+= lex_integer.c
163FILES+= lex_integer.exp 163FILES+= lex_integer.exp
 164FILES+= lex_integer_binary.c
 165FILES+= lex_integer_binary.exp
164FILES+= lex_integer_ilp32.c 166FILES+= lex_integer_ilp32.c
165FILES+= lex_integer_ilp32.exp 167FILES+= lex_integer_ilp32.exp
166FILES+= lex_string.c 168FILES+= lex_string.c
167FILES+= lex_string.exp 169FILES+= lex_string.exp
168FILES+= lex_wide_char.c 170FILES+= lex_wide_char.c
169FILES+= lex_wide_char.exp 171FILES+= lex_wide_char.exp
170FILES+= lex_wide_string.c 172FILES+= lex_wide_string.c
171FILES+= lex_wide_string.exp 173FILES+= lex_wide_string.exp
172FILES+= ${:U0 ${:U:${:Urange=${MAX_MESSAGE}}}:C,^.$,0&,:C,^..$,0&,:@i@msg_${i}.c msg_${i}.exp@:Nmsg_176.exp} 174FILES+= ${:U0 ${:U:${:Urange=${MAX_MESSAGE}}}:C,^.$,0&,:C,^..$,0&,:@i@msg_${i}.c msg_${i}.exp@:Nmsg_176.exp}
173FILES+= msg_001_c90.c 175FILES+= msg_001_c90.c
174FILES+= msg_001_c90.exp 176FILES+= msg_001_c90.exp
175FILES+= msg_000_c90.c 177FILES+= msg_000_c90.c
176FILES+= msg_000_c90.exp 178FILES+= msg_000_c90.exp

cvs diff -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/lex_integer.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/lex_integer.c 2021/07/10 18:42:28 1.5
+++ src/tests/usr.bin/xlint/lint1/lex_integer.c 2021/07/13 19:38:10 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lex_integer.c,v 1.5 2021/07/10 18:42:28 rillig Exp $ */ 1/* $NetBSD: lex_integer.c,v 1.6 2021/07/13 19:38:10 rillig Exp $ */
2# 3 "lex_integer.c" 2# 3 "lex_integer.c"
3 3
4/* 4/*
5 * Tests for lexical analysis of integer constants. 5 * Tests for lexical analysis of integer constants.
6 * 6 *
7 * C99 6.4.4.1 "Integer constants" 7 * C99 6.4.4.1 "Integer constants"
8 */ 8 */
9 9
10/* lint1-only-if lp64 */ 10/* lint1-only-if lp64 */
11 11
12void sinki(int); 12void sinki(int);
13void sinku(unsigned int); 13void sinku(unsigned int);
14 14
@@ -49,13 +49,20 @@ void sinkull(unsigned long long); @@ -49,13 +49,20 @@ void sinkull(unsigned long long);
49void 49void
50suffixes(void) 50suffixes(void)
51{ 51{
52 sinkull(3u); 52 sinkull(3u);
53 sinkull(3ll); 53 sinkull(3ll);
54 sinkull(3llu); 54 sinkull(3llu);
55 sinkull(3Ull); 55 sinkull(3Ull);
56 56
57 /* The 'LL' must not be split. Checked by the compiler. */ 57 /* The 'LL' must not be split. Checked by the compiler. */
58 sinkull(3lul); 58 sinkull(3lul);
59 /* The 'Ll' must not used mixed case. Checked by the compiler. */ 59 /* The 'Ll' must not used mixed case. Checked by the compiler. */
60 sinkull(3ULl); 60 sinkull(3ULl);
61} 61}
 62
 63/* https://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html */
 64void
 65binary_literal(void)
 66{
 67 sinku(0b1111000001011010);
 68}

File Added: src/tests/usr.bin/xlint/lint1/lex_integer_binary.c
/*	$NetBSD: lex_integer_binary.c,v 1.1 2021/07/13 19:38:10 rillig Exp $	*/
# 3 "lex_integer_binary.c"

/*
 * Test for parsing binary integer literals in non-GCC mode.
 * As of C11, binary integer literals are not supported.
 * Neither are underscores in integer literals.
 */

/* Remove the default -g flag. */
/* lint1-flags: -Ac11 -w */

void sink(unsigned int);

void
binary_literal(void)
{
	/*
	 * Binary integer literals are a GCC extension, but lint allows them
	 * even in non-GCC mode.
	 */
	sink(0b1111000001011010);

	/*
	 * Even though it would be useful for binary literals, GCC does not
	 * support underscores to separate the digit groups.
	 */
	/* expect+1: syntax error '_0000_0101_1010' [249] */
	sink(0b1111_0000_0101_1010);
}

File Added: src/tests/usr.bin/xlint/lint1/Attic/lex_integer_binary.exp
lex_integer_binary.c(29): error: syntax error '_0000_0101_1010' [249]