summaryrefslogtreecommitdiff
path: root/tests/usr.bin/indent/lsym_semicolon.c
blob: 80fef3f0199594fb93444c61601acd9db4027124 (plain)
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
/* $NetBSD: lsym_semicolon.c,v 1.6 2023/06/16 23:19:01 rillig Exp $ */

/*
 * Tests for the token lsym_semicolon, which represents ';' in these contexts:
 *
 * In a declaration, ';' finishes the declaration.
 *
 * In a statement, ';' finishes the statement.
 *
 * In a 'for' statement, ';' separates the 3 expressions in the head of the
 * 'for' statement.
 */

//indent input
struct {
	int member;
} global_var;
//indent end

//indent run-equals-input -di0


//indent input
void
function(void)
{
	for ( ; ; )
		stmt();
	for (;;)
		stmt();
}
//indent end

//indent run
void
function(void)
{
	for (;;)
		stmt();
	for (;;)
		stmt();
}
//indent end


//indent input
{
	switch (expr) {
// $ FIXME: Indent the 'case' at the 'switch'.
		case;
		stmt;
	case 2:
		stmt;
	}
}
//indent end

//indent run-equals-input


/*
 * A semicolon closes all possibly open '?:' expressions, so that the next ':'
 * is interpreted as a bit-field.
 */
//indent input
struct s {
	int a[len ? ? ? 1];
	int bit_field:1;
};
//indent end

//indent run-equals-input -di0


/*
 * A semicolon does not magically close any initializer braces that may still
 * be open.
 */
//indent input
int a = {{;
int b = 3;
//indent end

//indent run -di0
int a = {{;
		int b = 3;
// exit 1
// error: Standard Input:2: Stuff missing from end of file
//indent end


//indent input
{
	int a = {{;
	int b = 3;
}
//indent end

//indent run -di0
{
	int a = {{;
			int b = 3;
	}
// exit 1
// error: Standard Input:4: Stuff missing from end of file
//indent end