1 /* $NetBSD: lsym_semicolon.c,v 1.6 2023/06/16 23:19:01 rillig Exp $ */
2
3 /*
4 * Tests for the token lsym_semicolon, which represents ';' in these contexts:
5 *
6 * In a declaration, ';' finishes the declaration.
7 *
8 * In a statement, ';' finishes the statement.
9 *
10 * In a 'for' statement, ';' separates the 3 expressions in the head of the
11 * 'for' statement.
12 */
13
14 //indent input
15 struct {
16 int member;
17 } global_var;
18 //indent end
19
20 //indent run-equals-input -di0
21
22
23 //indent input
24 void
function(void)25 function(void)
26 {
27 for ( ; ; )
28 stmt();
29 for (;;)
30 stmt();
31 }
32 //indent end
33
34 //indent run
35 void
function(void)36 function(void)
37 {
38 for (;;)
39 stmt();
40 for (;;)
41 stmt();
42 }
43 //indent end
44
45
46 //indent input
47 {
48 switch (expr) {
49 // $ FIXME: Indent the 'case' at the 'switch'.
50 case;
51 stmt;
52 case 2:
53 stmt;
54 }
55 }
56 //indent end
57
58 //indent run-equals-input
59
60
61 /*
62 * A semicolon closes all possibly open '?:' expressions, so that the next ':'
63 * is interpreted as a bit-field.
64 */
65 //indent input
66 struct s {
67 int a[len ? ? ? 1];
68 int bit_field:1;
69 };
70 //indent end
71
72 //indent run-equals-input -di0
73
74
75 /*
76 * A semicolon does not magically close any initializer braces that may still
77 * be open.
78 */
79 //indent input
80 int a = {{;
81 int b = 3;
82 //indent end
83
84 //indent run -di0
85 int a = {{;
86 int b = 3;
87 // exit 1
88 // error: Standard Input:2: Stuff missing from end of file
89 //indent end
90
91
92 //indent input
93 {
94 int a = {{;
95 int b = 3;
96 }
97 //indent end
98
99 //indent run -di0
100 {
101 int a = {{;
102 int b = 3;
103 }
104 // exit 1
105 // error: Standard Input:4: Stuff missing from end of file
106 //indent end
107