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/lint1 tests/lint: test emitting format s...



details:   https://anonhg.NetBSD.org/src/rev/721ef675a8b5
branches:  trunk
changeset: 1023363:721ef675a8b5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Sep 04 15:13:00 2021 +0000

description:
tests/lint: test emitting format strings

diffstat:

 tests/usr.bin/xlint/lint1/emit.c      |  26 ++++++++++++++++-
 tests/usr.bin/xlint/lint1/emit.exp-ln |  51 ++++++++++++++++++++--------------
 2 files changed, 54 insertions(+), 23 deletions(-)

diffs (109 lines):

diff -r 3dd7e47d584a -r 721ef675a8b5 tests/usr.bin/xlint/lint1/emit.c
--- a/tests/usr.bin/xlint/lint1/emit.c  Sat Sep 04 14:58:42 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.c  Sat Sep 04 15:13:00 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: emit.c,v 1.5 2021/08/30 21:23:37 rillig Exp $  */
+/*     $NetBSD: emit.c,v 1.6 2021/09/04 15:13:00 rillig Exp $  */
 # 3 "emit.c"
 
 /*
@@ -146,6 +146,7 @@
 static int static_function(void);                      /* expect: declared */
 
 void my_printf(const char *, ...);
+void my_scanf(const char *, ...);
 
 /*
  * String literals that occur in function calls are written to the .ln file,
@@ -161,7 +162,14 @@
        my_printf("%s", "%");
        my_printf("%s", "%s");
        my_printf("%s", "%%");
-       my_printf("%s", "%\a %\b %\f %\n %\r %\t %\v %\177");
+       my_printf("%s", "%\\ %\" %' %\a %\b %\f %\n %\r %\t %\v %\177");
+}
+
+void
+cover_outfstrg(void)
+{
+       my_printf("%s", "%-3d %+3d % d %#x %03d %*.*s %6.2f %hd %ld %Ld %qd");
+       my_scanf("%s", "%[0-9]s %[^A-Za-z]s %[][A-Za-z0-9]s %[+-]s");
 }
 
 /*
@@ -263,3 +271,17 @@
        (void)used_function();
        return used_function();
 }
+
+extern int declared_used_var;
+int defined_used_var;
+
+/*
+ * When a function is used, that usage is output as a 'c' record.
+ * When a variable is used, that usage is output as a 'u' record.
+ */
+void
+use_vars(void)
+{
+       declared_used_var++;
+       defined_used_var++;
+}
diff -r 3dd7e47d584a -r 721ef675a8b5 tests/usr.bin/xlint/lint1/emit.exp-ln
--- a/tests/usr.bin/xlint/lint1/emit.exp-ln     Sat Sep 04 14:58:42 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.exp-ln     Sat Sep 04 15:13:00 2021 +0000
@@ -51,24 +51,33 @@
 138d0.138e14taking_varargsF2PcCEV
 146d0.146es15static_functionF0I
 148d0.148e9my_printfF2PcCEV
-161c0.161s2"%"i9my_printff2PcCPCV
-162c0.162s2"%s"i9my_printff2PcCPCV
-163c0.163s2"%%"i9my_printff2PcCPCV
-164c0.164s2"%\a%\b%\f%\n%\r%\t%\v%\177"i9my_printff2PcCPCV
-159d0.159d14cover_outqcharF0V
-173d0.173d17call_gcc_builtinsF2IPLV
-193d0.193v0d15varargs_commentF1PcCV
-199d0.199v0d17varargs_0_commentF1PcCV
-205d0.205v3d17varargs_3_commentF4IIIPcCV
-211d0.211d18printflike_commentF1PcCV
-217d0.217d20printflike_0_commentF1PcCV
-223d0.223v3P3d20printflike_3_commentF3IIPcCV
-229d0.229v10P10d21printflike_10_commentF10IIIIIIIIIPcCV
-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
+149d0.149e8my_scanfF2PcCEV
+162c0.162s2"%"i9my_printff2PcCPCV
+163c0.163s2"%s"i9my_printff2PcCPCV
+164c0.164s2"%%"i9my_printff2PcCPCV
+165c0.165s2"%\\%\"%\'%\a%\b%\f%\n%\r%\t%\v%\177"i9my_printff2PcCPCV
+160d0.160d14cover_outqcharF0V
+171c0.171s2"%-3d%+3d% d%#x%03d%*.*s%6.2f%hd%ld%Ld%qd"i9my_printff2PcCPCV
+172c0.172s2"%[-]%[--]%[---]%[]"i8my_scanff2PcCPCV
+169d0.169d14cover_outfstrgF0V
+181d0.181d17call_gcc_builtinsF2IPLV
+201d0.201v0d15varargs_commentF1PcCV
+207d0.207v0d17varargs_0_commentF1PcCV
+213d0.213v3d17varargs_3_commentF4IIIPcCV
+219d0.219d18printflike_commentF1PcCV
+225d0.225d20printflike_0_commentF1PcCV
+231d0.231v3P3d20printflike_3_commentF3IIPcCV
+237d0.237v10P10d21printflike_10_commentF10IIIIIIIIIPcCV
+245d0.245d17scanflike_commentF1PcCV
+251d0.251d19scanflike_0_commentF1PcCV
+257d0.257v3S3d19scanflike_3_commentF3IIPcCV
+262d0.262dr13used_functionF0I
+270c0.270i13used_functionf0I
+271c0.271d13used_functionf0I
+272c0.272u13used_functionf0I
+268d0.268dri15inline_functionF0I
+275d0.275e17declared_used_varI
+276d0.276t16defined_used_varI
+285u0.285x17declared_used_var
+286u0.286x16defined_used_var
+283d0.283d8use_varsF0V



Home | Main Index | Thread Index | Old Index