Module Name:    src
Committed By:   rillig
Date:           Tue Jun 29 09:19:17 UTC 2021

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/tests/usr.bin/xlint/lint1: Makefile msg_259.c msg_259.exp
            t_integration.sh
Added Files:
        src/tests/usr.bin/xlint/lint1: lex_integer_ilp32.c
            lex_integer_ilp32.exp msg_259_ilp32.c msg_259_ilp32.exp

Log Message:
tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on.  This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


To generate a diff of this commit:
cvs rdiff -u -r1.1067 -r1.1068 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.68 -r1.69 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c \
    src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.exp \
    src/tests/usr.bin/xlint/lint1/msg_259_ilp32.c \
    src/tests/usr.bin/xlint/lint1/msg_259_ilp32.exp
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_259.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_259.exp
cvs rdiff -u -r1.64 -r1.65 src/tests/usr.bin/xlint/lint1/t_integration.sh

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.1067 src/distrib/sets/lists/tests/mi:1.1068
--- src/distrib/sets/lists/tests/mi:1.1067	Sun Jun 27 19:10:29 2021
+++ src/distrib/sets/lists/tests/mi	Tue Jun 29 09:19:17 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1067 2021/06/27 19:10:29 rillig Exp $
+# $NetBSD: mi,v 1.1068 2021/06/29 09:19:17 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6228,6 +6228,8 @@
 ./usr/tests/usr.bin/xlint/lint1/lex_floating.exp		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/lex_integer.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/lex_integer.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/lex_integer_ilp32.exp		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/lex_string.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/lex_string.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/lex_wide_char.c			tests-usr.bin-tests	compattestfile,atf
@@ -6754,6 +6756,8 @@
 ./usr/tests/usr.bin/xlint/lint1/msg_258.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_259.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_259.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_259_ilp32.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_259_ilp32.exp		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_260.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_260.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_261.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.68 src/tests/usr.bin/xlint/lint1/Makefile:1.69
--- src/tests/usr.bin/xlint/lint1/Makefile:1.68	Sun Jun 27 19:10:29 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Tue Jun 29 09:19:17 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.68 2021/06/27 19:10:29 rillig Exp $
+# $NetBSD: Makefile,v 1.69 2021/06/29 09:19:17 rillig Exp $
 
 NOMAN=		# defined
 MAX_MESSAGE=	345		# see lint1/err.c
@@ -131,6 +131,8 @@ FILES+=		lex_floating.c
 FILES+=		lex_floating.exp
 FILES+=		lex_integer.c
 FILES+=		lex_integer.exp
+FILES+=		lex_integer_ilp32.c
+FILES+=		lex_integer_ilp32.exp
 FILES+=		lex_string.c
 FILES+=		lex_string.exp
 FILES+=		lex_wide_char.c
@@ -138,6 +140,8 @@ FILES+=		lex_wide_char.exp
 FILES+=		lex_wide_string.c
 FILES+=		lex_wide_string.exp
 FILES+=		${:U0 ${:U:${:Urange=${MAX_MESSAGE}}}:C,^.$,0&,:C,^..$,0&,:@i@msg_${i}.c msg_${i}.exp@:Nmsg_176.exp}
+FILES+=		msg_259_ilp32.c
+FILES+=		msg_259_ilp32.exp
 FILES+=		op_colon.c
 FILES+=		op_colon.exp
 FILES+=		stmt_for.c

Index: src/tests/usr.bin/xlint/lint1/msg_259.c
diff -u src/tests/usr.bin/xlint/lint1/msg_259.c:1.6 src/tests/usr.bin/xlint/lint1/msg_259.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_259.c:1.6	Thu Feb  4 07:39:39 2021
+++ src/tests/usr.bin/xlint/lint1/msg_259.c	Tue Jun 29 09:19:17 2021
@@ -1,8 +1,9 @@
-/*	$NetBSD: msg_259.c,v 1.6 2021/02/04 07:39:39 rillig Exp $	*/
+/*	$NetBSD: msg_259.c,v 1.7 2021/06/29 09:19:17 rillig Exp $	*/
 # 3 "msg_259.c"
 
 // Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259]
 
+/* lint1-only-on-lp64 */
 /* lint1-extra-flags: -h */
 
 void farg_char(char);

Index: src/tests/usr.bin/xlint/lint1/msg_259.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_259.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_259.exp:1.6
--- src/tests/usr.bin/xlint/lint1/msg_259.exp:1.5	Thu Feb  4 06:55:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_259.exp	Tue Jun 29 09:19:17 2021
@@ -1 +1 @@
-msg_259.c(22): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
+msg_259.c(23): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.64 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.65
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.64	Tue Jun 29 08:46:10 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Tue Jun 29 09:19:17 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.64 2021/06/29 08:46:10 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.65 2021/06/29 09:19:17 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -27,7 +27,7 @@
 
 lint1=/usr/libexec/lint1
 
-machine_arch="$(sysctl -n hw.machine_arch)"
+: "${machine_arch:="$(sysctl -n hw.machine_arch)"}"
 
 
 configure_test_case()

Added files:

Index: src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c:1.1
--- /dev/null	Tue Jun 29 09:19:18 2021
+++ src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c	Tue Jun 29 09:19:17 2021
@@ -0,0 +1,44 @@
+/*	$NetBSD: lex_integer_ilp32.c,v 1.1 2021/06/29 09:19:17 rillig Exp $	*/
+# 3 "lex_integer_ilp32.c"
+
+/*
+ * Tests for lexical analysis of integer constants.
+ *
+ * C99 6.4.4.1 "Integer constants"
+ */
+
+/* lint1-only-on-ilp32 */
+
+void sinki(int);
+void sinku(unsigned int);
+
+/* All platforms supported by lint have 32-bit int in two's complement. */
+void
+test_signed_int(void)
+{
+	sinki(0);
+
+	sinki(-1);
+
+	sinki(2147483647);
+
+	/* expect+1: 'unsigned long' to 'int' is out of range, arg #1 [295] */
+	sinki(2147483648);
+
+	sinki(-2147483647);
+
+	/* expect+2: ANSI C treats constant as unsigned, op - [218] */
+	/* expect+1: 'unsigned long' to 'int' is out of range, arg #1 [295] */
+	sinki(-2147483648);
+}
+
+void
+test_unsigned_int(void)
+{
+	sinku(0);
+
+	sinku(4294967295U);
+
+	/* expect+1: integer constant out of range [252] */
+	sinku(4294967296U);
+}
Index: src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.exp:1.1
--- /dev/null	Tue Jun 29 09:19:18 2021
+++ src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.exp	Tue Jun 29 09:19:17 2021
@@ -0,0 +1,4 @@
+lex_integer_ilp32.c(26): warning: conversion of 'unsigned long' to 'int' is out of range, arg #1 [295]
+lex_integer_ilp32.c(32): warning: ANSI C treats constant as unsigned, op - [218]
+lex_integer_ilp32.c(32): warning: conversion of 'unsigned long' to 'int' is out of range, arg #1 [295]
+lex_integer_ilp32.c(43): warning: integer constant out of range [252]
Index: src/tests/usr.bin/xlint/lint1/msg_259_ilp32.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_259_ilp32.c:1.1
--- /dev/null	Tue Jun 29 09:19:18 2021
+++ src/tests/usr.bin/xlint/lint1/msg_259_ilp32.c	Tue Jun 29 09:19:17 2021
@@ -0,0 +1,30 @@
+/*	$NetBSD: msg_259_ilp32.c,v 1.1 2021/06/29 09:19:17 rillig Exp $	*/
+# 3 "msg_259_ilp32.c"
+
+// Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259]
+
+/* lint1-only-on-ilp32 */
+/* lint1-extra-flags: -h */
+
+void farg_char(char);
+void farg_int(int);
+void farg_long(long);
+
+void
+example(char c, int i, long l)
+{
+	farg_char(c);
+	farg_int(c);
+	/* expect+1: from 'char' to 'long' due to prototype [259] */
+	farg_long(c);
+
+	farg_char(i);		/* XXX: why no warning? */
+	farg_int(i);
+	/* expect+1: from 'int' to 'long' due to prototype [259] */
+	farg_long(i);
+
+	farg_char(l);		/* XXX: why no warning? */
+	/* expect+1: from 'long' to 'int' due to prototype [259] */
+	farg_int(l);
+	farg_long(l);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_259_ilp32.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_259_ilp32.exp:1.1
--- /dev/null	Tue Jun 29 09:19:18 2021
+++ src/tests/usr.bin/xlint/lint1/msg_259_ilp32.exp	Tue Jun 29 09:19:17 2021
@@ -0,0 +1,3 @@
+msg_259_ilp32.c(19): warning: argument #1 is converted from 'char' to 'long' due to prototype [259]
+msg_259_ilp32.c(24): warning: argument #1 is converted from 'int' to 'long' due to prototype [259]
+msg_259_ilp32.c(28): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]

Reply via email to