xref: /netbsd-src/tests/usr.bin/xlint/lint1/lex_string.c (revision 122b5006ee1bd67145794b4cde92f4fe4781a5ec)
1 /*	$NetBSD: lex_string.c,v 1.3 2021/08/23 17:47:34 rillig Exp $	*/
2 # 3 "lex_string.c"
3 
4 /*
5  * Test lexical analysis of string constants.
6  *
7  * C99 6.4.5 "String literals"
8  */
9 
10 void sink(const char *);
11 
12 void
13 test(void)
14 {
15 	sink("");
16 
17 	sink("hello, world\n");
18 
19 	sink("\0");
20 
21 	sink("\0\0\0\0");
22 
23 	/* expect+1: no hex digits follow \x [74] */
24 	sink("\x");		/* unfinished */
25 
26 	/* expect+1: dubious escape \y [79] */
27 	sink("\y");		/* unknown escape sequence */
28 
29 	sink("first" "second");
30 
31 	/* expect+1: error: cannot concatenate wide and regular string literals [292] */
32 	sink("plain" L"wide");
33 }
34