xref: /netbsd-src/tests/usr.bin/xlint/lint2/read_printf.ln (revision b777f6c7cca9aad6754eca973ddfe8d3ca032cf4)
1# $NetBSD: read_printf.ln,v 1.3 2021/08/24 23:38:51 rillig Exp $
2#
3# Test reading of declarations and usage of printf-like functions.
4
5# void my_printf(const char *, ...);
60 s printf-def.c
7S printf-def.c
83 d 0.3 d 9my_printf F2 PcC E V
9
100 s printf-use.c
11S printf-use.c
12
13# my_printf("string %s", "string %s%%%3d");
14#
15# Argument 1 is converted to 'const char *', due to the function prototype.
16# After that, is it not a string literal anymore, therefore no information
17# about this argument is written to the .ln file.
18#
19# Argument 2 is part of the '...', therefore no conversion to 'const char *'
20# takes place.  Since it is still the address of a string, its value is
21# analyzed for printf format specifiers.  This is unnecessary though since in
22# this example, the format string is already in argument 1, but not 2.
2311 c 0.11 s2"%s%%%3d" i 9my_printf f2 PcC PC V
24
25# my_printf("int %d", 12345);
26#
27# Argument 2 is a positive integer.
2812 c 0.12 p2 i 9my_printf f2 PcC I V
29
30# my_printf("%s %d %p", "\t", -6, (const void *)0);
31#
32# Argument 2 is a string without any printf-like format specifiers.
33# Argument 3 is a negative integer.
34# Argument 4 has no further interesting properties.
3513 c 0.13 s2"" n3 i 9my_printf f4 PcC PC I PcV V
36
37# See tests/lint1/emit.c, function cover_outqchar.
38161 c 0.161 s2"%" i 9my_printf f2 PcC PC V
39162 c 0.162 s2"%s"i 9my_printf f2 PcC PC V
40163 c 0.163 s2"%%" i 9my_printf f2 PcC PC V
41164 c 0.164 s2"%\a%\b%\f%\n%\r%\t%\v%\177" i 9my_printf f2 PcC PC V
42