1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/* $NetBSD: lsym_typedef.c,v 1.9 2023/06/17 22:09:24 rillig Exp $ */
/*
* Tests for the token lsym_typedef, which represents the keyword 'typedef'
* for giving a type an additional name.
*/
/*
* Since 2019-04-04 and before lexi.c 1.169 from 2022-02-12, indent placed all
* enum constants except the first too far to the right, as if it were a
* statement continuation, but only if the enum declaration followed a
* 'typedef'.
*
* https://gnats.netbsd.org/55453
*/
//indent input
typedef enum {
TC1,
TC2
} T;
enum {
EC1,
EC2
} E;
//indent end
//indent run -ci4 -i4
typedef enum {
TC1,
TC2
} T;
enum {
EC1,
EC2
} E;
//indent end
//indent run -ci2
typedef enum {
TC1,
TC2
} T;
enum {
EC1,
EC2
} E;
//indent end
/*
* Contrary to declarations, type definitions are not affected by the option
* '-di'.
*/
//indent input
typedef int number;
//indent end
//indent run-equals-input
/*
* Ensure that a typedef declaration does not introduce an unnecessary line
* break after the '}'.
*/
//indent input
typedef struct {
int member;
bool bit:1;
} typedef_name;
struct {
int member;
bool bit:1;
} var_name;
//indent end
//indent run
typedef struct {
int member;
bool bit:1;
} typedef_name;
struct {
int member;
bool bit:1;
} var_name;
//indent end
//indent run-equals-input -di0
/*
* When 'typedef' or a tag is followed by a name, that name marks a type and a
* following '*' marks a pointer type.
*/
//indent input
{
// $ Syntactically invalid but shows that '*' is not multiplication.
a = typedef name * y;
a = (typedef x * y)z;
}
//indent end
//indent run
{
// $ Everything before the '*' is treated as a declaration.
a = typedef name *y;
a = (typedef x *y)z;
}
//indent end
|