summaryrefslogtreecommitdiff
path: root/tests/usr.bin/indent/psym_switch_expr.c
blob: 7140253ad4daa49247e8f8f381f78d4c3f699b6d (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
/* $NetBSD: psym_switch_expr.c,v 1.6 2023/06/23 20:44:51 rillig Exp $ */

/*
 * Tests for the parser symbol psym_switch_expr, which represents the keyword
 * 'switch' followed by the controlling expression, now waiting for a
 * statement (usually a block) containing the 'case' labels.
 */

//indent run-equals-input


/*
 * In all practical cases, a 'switch (expr)' is followed by a block, but the
 * C syntax allows an arbitrary statement.  Unless such a statement has a
 * label or is a loop, its beginning is unreachable.
 */
//indent input
void
function(void)
{
	switch (expr)
	if (cond) {
	case 1: return;
	case 2: break;
	}
}
//indent end

//indent run
void
function(void)
{
	switch (expr)
		if (cond) {
	case 1:
			return;
	case 2:
			break;
		}
}
//indent end

//indent run -cli-0.375
void
function(void)
{
	switch (expr)
		if (cond) {
     case 1:
			return;
     case 2:
			break;
		}
}
//indent end