xref: /netbsd-src/tests/usr.bin/xlint/lint1/lex_wide_char.c (revision 6f23d4df445f4631bf636eda60148f87f35b184f)
1 /*	$NetBSD: lex_wide_char.c,v 1.5 2024/01/19 19:23:34 rillig Exp $	*/
2 # 3 "lex_wide_char.c"
3 
4 /*
5  * Tests for lexical analysis of character constants.
6  *
7  * C99 6.4.4.4 "Character constants"
8  */
9 
10 /* lint1-extra-flags: -X 351 */
11 
12 void sink(int);
13 
14 void
test(void)15 test(void)
16 {
17 	/* expect+1: error: empty character constant [73] */
18 	sink(L'');
19 
20 	sink(L'a');
21 
22 	sink(L'\0');
23 
24 	/* UTF-8 */
25 	/* expect+1: error: too many characters in character constant [71] */
26 	sink(L'ä');
27 
28 	/* GCC extension */
29 	sink(L'\e');
30 
31 	/* expect+1: warning: dubious escape \y [79] */
32 	sink(L'\y');
33 
34 	/* since C99 */
35 	sink(L'\x12');
36 
37 	/* octal */
38 	sink(L'\177');
39 
40 	/* newline */
41 	sink(L'\n');
42 
43 	/* expect+1: error: empty character constant [73] */
44 	sink(L'');
45 }
46