1 /* $NetBSD: lex_wide_string.c,v 1.5 2024/02/02 22:45:48 rillig Exp $ */
2 # 3 "lex_wide_string.c"
3
4 /*
5 * Test lexical analysis of wide string constants.
6 *
7 * C99 6.4.5 "String literals"
8 */
9
10 /* lint1-extra-flags: -X 351 */
11
12 void sink(const int *);
13
14 void
test(void)15 test(void)
16 {
17 sink(L"");
18
19 sink(L"hello, world\n");
20
21 sink(L"\0");
22
23 sink(L"\0\0\0\0");
24
25 /* expect+1: error: no hex digits follow \x [74] */
26 sink(L"\x");
27
28 /* expect+1: warning: dubious escape \y [79] */
29 sink(L"\y");
30
31 sink(L"first" L"second");
32
33 /* expect+1: error: cannot concatenate wide and regular string literals [292] */
34 sink(L"wide" "plain");
35 }
36
37 /*
38 * Since lint always runs in the default "C" locale, it does not support any
39 * multibyte character encoding, thus treating each byte as a separate
40 * character. If lint were to support UTF-8, the array dimension would be 3
41 * instead of 7.
42 */
43 /* expect+1: error: negative array dimension (-7) [20] */
44 typedef int mblen[-(int)(sizeof(L"Ä") / sizeof(L""))];
45