Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint2 lint: allow libraries to use 128-bit int...
details: https://anonhg.NetBSD.org/src/rev/a5ba65bc2fbf
branches: trunk
changeset: 1023109:a5ba65bc2fbf
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Aug 24 21:30:52 2021 +0000
description:
lint: allow libraries to use 128-bit integer types
diffstat:
distrib/sets/lists/tests/mi | 6 +++-
tests/usr.bin/xlint/lint2/Makefile | 8 ++++-
tests/usr.bin/xlint/lint2/emit.exp-ln | 18 +++++++++++++
tests/usr.bin/xlint/lint2/emit.ln | 41 ++++++++++++++++++++++++++++++
tests/usr.bin/xlint/lint2/emit_lp64.exp-ln | 7 +++++
tests/usr.bin/xlint/lint2/emit_lp64.ln | 11 ++++++++
tests/usr.bin/xlint/lint2/t_lint2.sh | 40 +++++++++++++++++++++++++++--
usr.bin/xlint/lint2/emit2.c | 8 ++++-
8 files changed, 131 insertions(+), 8 deletions(-)
diffs (234 lines):
diff -r 40c6c37db0f4 -r a5ba65bc2fbf distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Tue Aug 24 20:23:38 2021 +0000
+++ b/distrib/sets/lists/tests/mi Tue Aug 24 21:30:52 2021 +0000
@@ -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
diff -r 40c6c37db0f4 -r a5ba65bc2fbf tests/usr.bin/xlint/lint2/Makefile
--- a/tests/usr.bin/xlint/lint2/Makefile Tue Aug 24 20:23:38 2021 +0000
+++ b/tests/usr.bin/xlint/lint2/Makefile Tue Aug 24 21:30:52 2021 +0000
@@ -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 @@
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_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.
diff -r 40c6c37db0f4 -r a5ba65bc2fbf tests/usr.bin/xlint/lint2/emit.exp-ln
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint2/emit.exp-ln Tue Aug 24 21:30:52 2021 +0000
@@ -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
diff -r 40c6c37db0f4 -r a5ba65bc2fbf tests/usr.bin/xlint/lint2/emit.ln
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint2/emit.ln Tue Aug 24 21:30:52 2021 +0000
@@ -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
diff -r 40c6c37db0f4 -r a5ba65bc2fbf tests/usr.bin/xlint/lint2/emit_lp64.exp-ln
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint2/emit_lp64.exp-ln Tue Aug 24 21:30:52 2021 +0000
@@ -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
diff -r 40c6c37db0f4 -r a5ba65bc2fbf tests/usr.bin/xlint/lint2/emit_lp64.ln
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint2/emit_lp64.ln Tue Aug 24 21:30:52 2021 +0000
@@ -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
diff -r 40c6c37db0f4 -r a5ba65bc2fbf tests/usr.bin/xlint/lint2/t_lint2.sh
--- a/tests/usr.bin/xlint/lint2/t_lint2.sh Tue Aug 24 20:23:38 2021 +0000
+++ b/tests/usr.bin/xlint/lint2/t_lint2.sh Tue Aug 24 21:30:52 2021 +0000
@@ -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 @@
"$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 @@
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
}
diff -r 40c6c37db0f4 -r a5ba65bc2fbf usr.bin/xlint/lint2/emit2.c
--- a/usr.bin/xlint/lint2/emit2.c Tue Aug 24 20:23:38 2021 +0000
+++ b/usr.bin/xlint/lint2/emit2.c Tue Aug 24 21:30:52 2021 +0000
@@ -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 @@
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;
Home |
Main Index |
Thread Index |
Old Index