Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/xlint tests/lint: test writing and reading .ln...



details:   https://anonhg.NetBSD.org/src/rev/2492f8475084
branches:  trunk
changeset: 985576:2492f8475084
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Aug 30 21:23:37 2021 +0000

description:
tests/lint: test writing and reading .ln files

The test case for reading varargs functions is no longer necessary, the
code is covered by the newly added tests as well.

Test inline function and return value usage.

diffstat:

 tests/usr.bin/xlint/lint1/emit.c      |  16 +++++++++++++++-
 tests/usr.bin/xlint/lint1/emit.exp-ln |   5 +++++
 tests/usr.bin/xlint/lint2/read.exp    |   5 ++++-
 tests/usr.bin/xlint/lint2/read.ln     |  25 +++++++++++++++++++------
 4 files changed, 43 insertions(+), 8 deletions(-)

diffs (102 lines):

diff -r 8e9b958d1fd3 -r 2492f8475084 tests/usr.bin/xlint/lint1/emit.c
--- a/tests/usr.bin/xlint/lint1/emit.c  Mon Aug 30 20:52:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.c  Mon Aug 30 21:23:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: emit.c,v 1.4 2021/08/30 19:48:21 rillig Exp $  */
+/*     $NetBSD: emit.c,v 1.5 2021/08/30 21:23:37 rillig Exp $  */
 # 3 "emit.c"
 
 /*
@@ -249,3 +249,17 @@
 scanflike_3_comment(int a, int b, const char *fmt)
 {
 }
+
+int
+used_function(void)
+{
+       return 4;
+}
+
+inline int
+inline_function(void)
+{
+       used_function();
+       (void)used_function();
+       return used_function();
+}
diff -r 8e9b958d1fd3 -r 2492f8475084 tests/usr.bin/xlint/lint1/emit.exp-ln
--- a/tests/usr.bin/xlint/lint1/emit.exp-ln     Mon Aug 30 20:52:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.exp-ln     Mon Aug 30 21:23:37 2021 +0000
@@ -67,3 +67,8 @@
 237d0.237d17scanflike_commentF1PcCV
 243d0.243d19scanflike_0_commentF1PcCV
 249d0.249v3S3d19scanflike_3_commentF3IIPcCV
+254d0.254dr13used_functionF0I
+262c0.262i13used_functionf0I
+263c0.263d13used_functionf0I
+264c0.264u13used_functionf0I
+260d0.260dri15inline_functionF0I
diff -r 8e9b958d1fd3 -r 2492f8475084 tests/usr.bin/xlint/lint2/read.exp
--- a/tests/usr.bin/xlint/lint2/read.exp        Mon Aug 30 20:52:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint2/read.exp        Mon Aug 30 21:23:37 2021 +0000
@@ -1,5 +1,6 @@
 a125 declared( read.c(125) ), but never used or defined
-bpf_set_error defined( read.c(400) ), but never used
+inline_function defined( read.c(256) ), but never used
+inline_function value declared inconsistently (void != int)    read.c(256)  ::  read.c(260)
 printflike_0_comment defined( read.c(217) ), but never used
 printflike_10_comment defined( read.c(229) ), but never used
 printflike_3_comment defined( read.c(223) ), but never used
@@ -7,6 +8,8 @@
 scanflike_0_comment defined( read.c(243) ), but never used
 scanflike_3_comment defined( read.c(249) ), but never used
 scanflike_comment defined( read.c(237) ), but never used
+used_function value declared inconsistently (int != void)      read.c(254)  ::  read.c(253)
+used_function returns value which is sometimes ignored
 varargs_0_comment defined( read.c(199) ), but never used
 varargs_3_comment defined( read.c(205) ), but never used
 varargs_comment defined( read.c(193) ), but never used
diff -r 8e9b958d1fd3 -r 2492f8475084 tests/usr.bin/xlint/lint2/read.ln
--- a/tests/usr.bin/xlint/lint2/read.ln Mon Aug 30 20:52:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint2/read.ln Mon Aug 30 21:23:37 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: read.ln,v 1.4 2021/08/30 20:11:56 rillig Exp $
+# $NetBSD: read.ln,v 1.5 2021/08/30 21:23:37 rillig Exp $
 #
 # Cover each path of reading declarations, definitions and usages.
 
@@ -63,11 +63,6 @@
 # void f302(const volatile int *);
 303 d 0.303 e 4f303 F1 PcvI V
 
-# The "cleanup" in read.c 1.58 produced "not a number: v0...".
-# The corresponding tests for parsing vararg, printflike and scanflike are
-# still missing, that's why it got through unnoticed.
-400 d 0.439 v0 d 13bpf_set_error F3 PsT115_compiler_state PcC E V
-
 # Taken from ../lint1/emit.exp-ln.
 193 d 0.193 v0 d 15varargs_comment   F1 PcC V
 199 d 0.199 v0 d 17varargs_0_comment F1 PcC V
@@ -81,3 +76,21 @@
 237 d 0.237         d 17scanflike_comment     F1  PcC V
 243 d 0.243         d 19scanflike_0_comment   F1  PcC V
 249 d 0.249 v3  S3  d 19scanflike_3_comment   F3  I I PcC V
+#
+253 d 0.253 e   13used_function F0 V
+258 c 0.258 i   13used_function f0 V
+# In a function definition, 'i' means 'inline'.
+256 d 0.256 d i 15inline_function F0 V
+
+# In a function definition, 'r' means the function returns a value, in
+# contrast to having a mere 'return;' without any expression.
+# This distinction is mainly relevant for non-prototype functions.
+254 d 0.254 d r   13used_function F0 I
+# In a function call, 'i' means 'return value ignored'.
+262 c 0.262 i     13used_function f0 I
+# In a function call, 'd' means 'return value discarded'.
+263 c 0.263 d     13used_function f0 I
+# In a function call, 'u' means 'return value used'.
+264 c 0.264 u     13used_function f0 I
+# This function is 'inline' and 'has return value'.
+260 d 0.260 d r i 15inline_function F0 I



Home | Main Index | Thread Index | Old Index