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