Module Name: src Committed By: rillig Date: Tue Aug 24 21:30:52 UTC 2021
Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/xlint/lint2: Makefile t_lint2.sh src/usr.bin/xlint/lint2: emit2.c Added Files: src/tests/usr.bin/xlint/lint2: emit.exp-ln emit.ln emit_lp64.exp-ln emit_lp64.ln Log Message: lint: allow libraries to use 128-bit integer types To generate a diff of this commit: cvs rdiff -u -r1.1115 -r1.1116 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint2/Makefile cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint2/emit.exp-ln \ src/tests/usr.bin/xlint/lint2/emit.ln \ src/tests/usr.bin/xlint/lint2/emit_lp64.exp-ln \ src/tests/usr.bin/xlint/lint2/emit_lp64.ln cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint2/t_lint2.sh cvs rdiff -u -r1.19 -r1.20 src/usr.bin/xlint/lint2/emit2.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.1115 src/distrib/sets/lists/tests/mi:1.1116 --- src/distrib/sets/lists/tests/mi:1.1115 Tue Aug 24 20:23:38 2021 +++ src/distrib/sets/lists/tests/mi Tue Aug 24 21:30:52 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1115 2021/08/24 20:23:38 rillig Exp $ +# $NetBSD: mi,v 1.1116 2021/08/24 21:30:52 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -7039,6 +7039,10 @@ ./usr/tests/usr.bin/xlint/lint2 tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint2/Atffile tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint2/Kyuafile tests-usr.bin-tests compattestfile,atf,kyua +./usr/tests/usr.bin/xlint/lint2/emit.exp-ln tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/emit.ln tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/emit_lp64.exp-ln tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint2/emit_lp64.ln tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint2/msg_000.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint2/msg_000.ln tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint2/msg_001.exp tests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/xlint/lint2/Makefile diff -u src/tests/usr.bin/xlint/lint2/Makefile:1.6 src/tests/usr.bin/xlint/lint2/Makefile:1.7 --- src/tests/usr.bin/xlint/lint2/Makefile:1.6 Sun Aug 8 16:35:15 2021 +++ src/tests/usr.bin/xlint/lint2/Makefile Tue Aug 24 21:30:52 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.6 2021/08/08 16:35:15 rillig Exp $ +# $NetBSD: Makefile,v 1.7 2021/08/24 21:30:52 rillig Exp $ NOMAN= yes @@ -10,6 +10,8 @@ TESTS_SH= t_lint2 FILESDIR= ${TESTSDIR} +TESTS+= emit +TESTS+= emit_lp64 .for msg in \ 000 001 002 003 004 005 006 007 008 009 \ 010 011 012 013 014 015 016 017 018 @@ -19,7 +21,9 @@ TESTS+= read TESTS+= read_lp64 TESTS+= read_printf -FILES+= ${TESTS:=.ln} ${TESTS:=.exp} +FILES+= ${TESTS:=.ln} +FILES+= ${TESTS:Nemit*:=.exp} +FILES+= ${TESTS:Memit*:=.exp-ln} # Note: only works for adding tests. # To remove a test, the $$mi file must be edited manually. Index: src/tests/usr.bin/xlint/lint2/t_lint2.sh diff -u src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.5 src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.6 --- src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.5 Sun Aug 8 16:35:15 2021 +++ src/tests/usr.bin/xlint/lint2/t_lint2.sh Tue Aug 24 21:30:52 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_lint2.sh,v 1.5 2021/08/08 16:35:15 rillig Exp $ +# $NetBSD: t_lint2.sh,v 1.6 2021/08/24 21:30:52 rillig Exp $ # # Copyright (c) 2021 The NetBSD Foundation, Inc. # All rights reserved. @@ -46,8 +46,40 @@ std_body() "$lint2" -h -p -x "$1.ln" } +std_emit_body() +{ + # shellcheck disable=SC2155 + local srcdir="$(atf_get_srcdir)" + + # remove comments and whitespace from the .ln files + sed -e '/^#/d' -e '/^$/d' -e 's,#.*,,' -e 's,[[:space:]],,g' \ + < "$srcdir/$1.ln" \ + > "$1.ln" + sed -e '/^#/d' -e '/^$/d' -e 's,#.*,,' -e 's,[[:space:]],,g' \ + < "$srcdir/$1.exp-ln" \ + > "$1.exp-ln" + + atf_check \ + "$lint2" -h -p -x -C "$1" "$1.ln" + + atf_check -o "file:$1.exp-ln" \ + cat "llib-l$1.ln" +} + +emit_body() +{ + std_emit_body 'emit' +} + +emit_lp64_body() +{ + std_emit_body 'emit_lp64' +} + atf_init_test_cases() { + local i + # shellcheck disable=SC2013 for i in $(cd "$(atf_get_srcdir)" && echo *.ln); do i=${i%.ln} @@ -60,8 +92,10 @@ atf_init_test_cases() esac esac - eval "${i}_head() { std_head; }" - eval "${i}_body() { std_body '$i'; }" + type "${i}_head" 1>/dev/null 2>&1 \ + || eval "${i}_head() { std_head; }" + type "${i}_body" 1>/dev/null 2>&1 \ + || eval "${i}_body() { std_body '$i'; }" atf_add_test_case "$i" done } Index: src/usr.bin/xlint/lint2/emit2.c diff -u src/usr.bin/xlint/lint2/emit2.c:1.19 src/usr.bin/xlint/lint2/emit2.c:1.20 --- src/usr.bin/xlint/lint2/emit2.c:1.19 Fri Apr 2 12:16:50 2021 +++ src/usr.bin/xlint/lint2/emit2.c Tue Aug 24 21:30:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: emit2.c,v 1.19 2021/04/02 12:16:50 rillig Exp $ */ +/* $NetBSD: emit2.c,v 1.20 2021/08/24 21:30:52 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -34,7 +34,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: emit2.c,v 1.19 2021/04/02 12:16:50 rillig Exp $"); +__RCSID("$NetBSD: emit2.c,v 1.20 2021/08/24 21:30:52 rillig Exp $"); #endif #include "lint2.h" @@ -70,6 +70,10 @@ outtype(type_t *tp) case ULONG: t = 'L'; s = 'u'; break; case QUAD: t = 'Q'; s = '\0'; break; case UQUAD: t = 'Q'; s = 'u'; break; +#ifdef INT128_SIZE + case INT128: t = 'J'; s = '\0'; break; + case UINT128: t = 'J'; s = 'u'; break; +#endif case FLOAT: t = 'D'; s = 's'; break; case DOUBLE: t = 'D'; s = '\0'; break; case LDOUBLE: t = 'D'; s = 'l'; break; Added files: Index: src/tests/usr.bin/xlint/lint2/emit.exp-ln diff -u /dev/null src/tests/usr.bin/xlint/lint2/emit.exp-ln:1.1 --- /dev/null Tue Aug 24 21:30:52 2021 +++ src/tests/usr.bin/xlint/lint2/emit.exp-ln Tue Aug 24 21:30:52 2021 @@ -0,0 +1,18 @@ +# $NetBSD: emit.exp-ln,v 1.1 2021/08/24 21:30:52 rillig Exp $ + +S llib-lemit.ln +0s llib-lemit.ln + +# Normally, it does not matter in which filename a particular symbol is +# defined. Only in cases where a file defines an anonymous tag type (struct, +# union, enum), its name is included in the resulting library. In this +# particular case, it would not be necessary though since none of the exported +# symbols actually refers to one of these anonymous types. +1s emit.c +2s expr_promote.c + +# from emit.c +0 d 0.0 t u 11defined_int I +0 d 0.0 d u 14cover_outqchar F0 V +# from expr_promote.c +0 d 0.0 d u 6caller F1 PsT116arithmetic_types V Index: src/tests/usr.bin/xlint/lint2/emit.ln diff -u /dev/null src/tests/usr.bin/xlint/lint2/emit.ln:1.1 --- /dev/null Tue Aug 24 21:30:52 2021 +++ src/tests/usr.bin/xlint/lint2/emit.ln Tue Aug 24 21:30:52 2021 @@ -0,0 +1,41 @@ +# $NetBSD: emit.ln,v 1.1 2021/08/24 21:30:52 rillig Exp $ +# +# Test emitting a lint library file. + +# Extracted from ../lint1/emit.exp-ln. +0s emit.c +S emit.c + +# Global variables that are declared using 'extern' are not part of a +# library's interface, therefore they are omitted from the output. +101 d 0.101 e 12extern__Bool B + +# Global variables that are defined, not only declared, are part of a +# library's interface. +106 d 0.106 t 11defined_int I + +# Referring to an anonymous tagged type forces the source file to be listed as +# part of the library. If it weren't listed, the diagnostics from lint2 were +# not able to refer to the location where this type has been defined. +97 d 0.97 e 21extern_anonymous_enum eT395.0.0 + +# Function declarations, as opposed to function definitions, are not part of a +# library's interface, therefore they are omitted from the output. +121 d 0.121 e 30return_void_unknown_parameters F V +122 d 0.122 e 38return_implicit_int_unknown_parameters F I +125 d 0.125 e 32extern_return_void_no_parameters F 0 V + +# Function calls are not part of a library's interface, therefore they are +# omitted from the output. +161 c 0.161 s2 "%" i 9my_printf f2 PcC PC V + +# Function definitions are copied to the output. +159 d 0.159 d 14cover_outqchar F0 V + +# Taken from ../lint1/expr_promote.exp-ln. +0s expr_promote.c +S expr_promote.c + +10 d 0.10 e 4sink F2 PcC E V +58 c 0.58 i 4sink f20 PcC B I I I I I I uI L uL Q uQ D D lD sX X lX eT331.0.0 V +37 d 0.37 d 6caller F1 PsT116arithmetic_types V Index: src/tests/usr.bin/xlint/lint2/emit_lp64.exp-ln diff -u /dev/null src/tests/usr.bin/xlint/lint2/emit_lp64.exp-ln:1.1 --- /dev/null Tue Aug 24 21:30:52 2021 +++ src/tests/usr.bin/xlint/lint2/emit_lp64.exp-ln Tue Aug 24 21:30:52 2021 @@ -0,0 +1,7 @@ +# $NetBSD: emit_lp64.exp-ln,v 1.1 2021/08/24 21:30:52 rillig Exp $ + +S llib-lemit_lp64.ln +0s llib-lemit_lp64.ln + +0 d 0.0 du 16uint128_function F0 uJ +0 d 0.0 tu 15int128_variable J Index: src/tests/usr.bin/xlint/lint2/emit_lp64.ln diff -u /dev/null src/tests/usr.bin/xlint/lint2/emit_lp64.ln:1.1 --- /dev/null Tue Aug 24 21:30:52 2021 +++ src/tests/usr.bin/xlint/lint2/emit_lp64.ln Tue Aug 24 21:30:52 2021 @@ -0,0 +1,11 @@ +# $NetBSD: emit_lp64.ln,v 1.1 2021/08/24 21:30:52 rillig Exp $ +# +# Test emitting a lint library file on an LP64 platform. + +0s first-file.c +S first-file.c +10 d 0.10 t 15int128_variable J + +0s second-file.c +S second-file.c +20 d 0.20 d 16uint128_function F0 uJ