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 passing of printf-like ...



details:   https://anonhg.NetBSD.org/src/rev/379bd70dcd94
branches:  trunk
changeset: 985104:379bd70dcd94
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 08 11:07:19 2021 +0000

description:
tests/lint: test passing of printf-like strings between lint1 and lint2

diffstat:

 tests/usr.bin/xlint/lint1/emit.c         |  21 ++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/emit.exp-ln    |   6 ++++++
 tests/usr.bin/xlint/lint2/read_printf.ln |   8 +++++++-
 3 files changed, 33 insertions(+), 2 deletions(-)

diffs (64 lines):

diff -r e96628531984 -r 379bd70dcd94 tests/usr.bin/xlint/lint1/emit.c
--- a/tests/usr.bin/xlint/lint1/emit.c  Sun Aug 08 10:59:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.c  Sun Aug 08 11:07:19 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: emit.c,v 1.1 2021/04/18 20:02:56 rillig Exp $  */
+/*     $NetBSD: emit.c,v 1.2 2021/08/08 11:07:19 rillig Exp $  */
 # 3 "emit.c"
 
 /*
@@ -144,3 +144,22 @@
  * it.
  */
 static int static_function(void);                      /* expect: declared */
+
+void my_printf(const char *, ...);
+
+/*
+ * String literals that occur in function calls are written to the .ln file,
+ * just in case they are related to a printf-like or scanf-like function.
+ *
+ * In this example, the various strings are not format strings, they just
+ * serve to cover the code that escapes character literals (outqchar in
+ * lint1) and reads them back into characters (inpqstrg in lint2).
+ */
+void
+cover_outqchar(void)
+{
+       my_printf("%s", "%");
+       my_printf("%s", "%s");
+       my_printf("%s", "%%");
+       my_printf("%s", "%\a %\b %\f %\n %\r %\t %\v %\177");
+}
diff -r e96628531984 -r 379bd70dcd94 tests/usr.bin/xlint/lint1/emit.exp-ln
--- a/tests/usr.bin/xlint/lint1/emit.exp-ln     Sun Aug 08 10:59:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.exp-ln     Sun Aug 08 11:07:19 2021 +0000
@@ -50,3 +50,9 @@
 136d0.135e33taking_struct_union_enum_typedefsF3sT214struct_typedefuT213union_typedefeT212enum_typedefV
 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
diff -r e96628531984 -r 379bd70dcd94 tests/usr.bin/xlint/lint2/read_printf.ln
--- a/tests/usr.bin/xlint/lint2/read_printf.ln  Sun Aug 08 10:59:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint2/read_printf.ln  Sun Aug 08 11:07:19 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: read_printf.ln,v 1.1 2021/08/07 23:52:32 rillig Exp $
+# $NetBSD: read_printf.ln,v 1.2 2021/08/08 11:07:19 rillig Exp $
 #
 # Test reading of declarations and usage of printf-like functions.
 
@@ -33,3 +33,9 @@
 # Argument 3 is a negative integer.
 # Argument 4 has no further interesting properties.
 13c0.13 s2"" n3 i 9my_printf f4 PcC PC I PcV V
+
+# See tests/lint1/emit.c, function cover_outqchar.
+161c0.161 s2"%" i 9my_printf f2 PcC PC V
+162c0.162 s2"%s"i 9my_printf f2 PcC PC V
+163c0.163 s2"%%" i 9my_printf f2 PcC PC V
+164c0.164 s2"%\a%\b%\f%\n%\r%\t%\v%\177" i 9my_printf f2 PcC PC V



Home | Main Index | Thread Index | Old Index