lex_ident.c revision 1.4
1/* $NetBSD: lex_ident.c,v 1.4 2022/04/22 21:21:20 rillig Exp $ */
2
3/*
4 * Test lexing of word-like tokens, such as keywords, identifiers, numeric
5 * constants, character constants, string literals.
6 */
7
8/*
9 * Conceptually, backslash-newline is replaced with nothing, in a very early
10 * stage of the translation, see C11 5.1.1.2p1, item 2. Indent does not
11 * preserve these; in most cases, they are simply removed.
12 */
13#indent input
14in\
15t \
16var\
17iable;
18
19int
20	no_backslash;
21
22/* $ See check_size_token. */
23/* $ The default buffer size is 200, the limit is 195. */
24struct long_tag_name_to_overflow_the_token_buffer_4567890\
2512345678901234567890123456789012345678901234567890\
2612345678901234567890123456789012345678901234567890\
2712345678901234567890123456789012345678901234567890;
28
29/* $ See check_size_token. */
30/* $ The difference between limit and start got incremented to 595. */
31struct long_tag_name_to_overflow_the_token_buffer_4567890\
3212345678901234567890123456789012345678901234567890\
3312345678901234567890123456789012345678901234567890\
3412345678901234567890123456789012345678901234567890\
3512345678901234567890123456789012345678901234567890\
3612345678901234567890123456789012345678901234567890\
3712345678901234567890123456789012345678901234567890\
3812345678901234567890123456789012345678901234567890\
3912345678901234567890123456789012345678901234567890\
4012345678901234567890123456789012345678901234567890\
4112345678901234567890123456789012345678901234567890\
4212345678901234567890123456789012345678901234567890;
43#indent end
44
45#indent run
46/* $ XXX: The indentation of the backslash is one short of a tab. */
47int	       \
48		variable;
49
50int
51		no_backslash;
52
53struct long_tag_name_to_overflow_the_token_buffer_4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890;
54
55struct long_tag_name_to_overflow_the_token_buffer_45678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890;
56#indent end
57
58
59/* This is a syntax error; see lex_word. */
60#indent input
61int identifier\n;
62#indent end
63
64#indent run
65int		identifier \ n;
66#indent end
67