Module Name:    src
Committed By:   rillig
Date:           Mon Aug 30 21:23:37 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: emit.c emit.exp-ln
        src/tests/usr.bin/xlint/lint2: read.exp read.ln

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/emit.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/emit.exp-ln
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint2/read.exp
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint2/read.ln

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/emit.c
diff -u src/tests/usr.bin/xlint/lint1/emit.c:1.4 src/tests/usr.bin/xlint/lint1/emit.c:1.5
--- src/tests/usr.bin/xlint/lint1/emit.c:1.4	Mon Aug 30 19:48:21 2021
+++ src/tests/usr.bin/xlint/lint1/emit.c	Mon Aug 30 21:23:37 2021
@@ -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 @@ void
 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();
+}

Index: src/tests/usr.bin/xlint/lint1/emit.exp-ln
diff -u src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.5 src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.6
--- src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.5	Mon Aug 30 19:48:21 2021
+++ src/tests/usr.bin/xlint/lint1/emit.exp-ln	Mon Aug 30 21:23:37 2021
@@ -67,3 +67,8 @@ Semit.c
 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

Index: src/tests/usr.bin/xlint/lint2/read.exp
diff -u src/tests/usr.bin/xlint/lint2/read.exp:1.3 src/tests/usr.bin/xlint/lint2/read.exp:1.4
--- src/tests/usr.bin/xlint/lint2/read.exp:1.3	Mon Aug 30 20:11:56 2021
+++ src/tests/usr.bin/xlint/lint2/read.exp	Mon Aug 30 21:23:37 2021
@@ -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 @@ printflike_comment defined( read.c(211) 
 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

Index: src/tests/usr.bin/xlint/lint2/read.ln
diff -u src/tests/usr.bin/xlint/lint2/read.ln:1.4 src/tests/usr.bin/xlint/lint2/read.ln:1.5
--- src/tests/usr.bin/xlint/lint2/read.ln:1.4	Mon Aug 30 20:11:56 2021
+++ src/tests/usr.bin/xlint/lint2/read.ln	Mon Aug 30 21:23:37 2021
@@ -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 @@ S read.c
 # 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 @@ S read.c
 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

Reply via email to