summaryrefslogtreecommitdiff
path: root/tests/usr.bin/indent/psym_switch_expr.c
blob: a98b11ea33973c8971af69a767b3e64caedbdec6 (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
/* $NetBSD: psym_switch_expr.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */
/* $FreeBSD$ */

/*
 * 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 input
// TODO: add input
#indent end

#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, it 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