summaryrefslogtreecommitdiff
path: root/tests/usr.bin/indent/psym_do.c
blob: 14f0e6e35070b79105ede6744f5ba9450c8eeb2a (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
/* $NetBSD: psym_do.c,v 1.5 2023/06/05 08:10:25 rillig Exp $ */

/*
 * Tests for the parser symbol psym_do, which represents the state after
 * reading the token 'do', now waiting for the statement of the loop body.
 *
 * See also:
 *	lsym_do.c
 *	psym_do_stmt.c
 */

//indent input
void function(void) {
	do stmt(); while (0);
	do {} while (0);
}
//indent end

//indent run
void
function(void)
{
	do
		stmt();
	while (0);
	do {
	} while (0);
}
//indent end


/*
 * The keyword 'do' is followed by a statement, as opposed to 'while', which
 * is followed by a parenthesized expression.
 */
//indent input
void
function(void)
{
	do(var)--;while(var>0);
}
//indent end

//indent run
void
function(void)
{
	do
		(var)--;
	while (var > 0);
}
//indent end