xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_356.c (revision 64230f321743248c221004acf3fa5c979d92e7e9)
1 /*	$NetBSD: msg_356.c,v 1.3 2024/03/25 22:37:43 rillig Exp $	*/
2 # 3 "msg_356.c"
3 
4 // Test for message: short octal escape '%.*s' followed by digit '%c' [356]
5 
6 /* lint1-extra-flags: -X 351 */
7 
8 // When counting backwards in octal, the number before \040 is not \039 but
9 // \037. This mistake sometimes happens when encoding the bit numbers for
10 // snprintb(3) format conversions.
11 
12 char snprintb_fmt[] = "\020"
13     "\0040bit32"		// 3-digit octal escapes are fine
14     "\0039bit31"
15     "\0038bit30"
16 
17     "\040bit32"
18     /* expect+1: warning: short octal escape '\03' followed by digit '9' [356] */
19     "\039bit31"
20     /* expect+1: warning: short octal escape '\03' followed by digit '8' [356] */
21     "\038bit30"
22 
23     "\40bit32"
24     /* expect+1: warning: short octal escape '\3' followed by digit '9' [356] */
25     "\39bit31"
26     /* expect+1: warning: short octal escape '\3' followed by digit '8' [356] */
27     "\38bit30"
28     "\37bit29"
29 ;
30 
31 char ok[] = ""
32     "\3\70"			// short octal followed by escaped '8'
33     "\3\x38"			// short octal followed by escaped '8'
34     "\3" "8"			// short octal and '8' are separated
35 ;
36