summaryrefslogtreecommitdiff
path: root/tests/usr.bin/indent/psym_stmt.c
blob: 9c68f1c41958f322952e3bff710a2960fe039a26 (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
/* $NetBSD: psym_stmt.c,v 1.7 2023/06/14 07:20:55 rillig Exp $ */

/*
 * Tests for the parser symbol psym_stmt, which represents a statement on the
 * stack.
 *
 * TODO: Explain why the stack contains 'lbrace' 'stmt' instead of only 'lbrace'.
 */

//indent input
#define unless(cond) if (!(cond))

void
function(void)
{
	stmt();
	stmt;			/* probably some macro */

	unless(cond)
		stmt();
}
//indent end

/*
 * There is no space after 'unless' since indent cannot know that it is a
 * syntactic macro, especially not when its definition is in a header file.
 */
//indent run-equals-input


// Ensure that '(something) {' is not treated as a cast expression.
//indent input
{
	TAILQ_FOREACH(a, b, c) {
		a =
		    b;
	}
}
//indent end

//indent run-equals-input -di0 -nlp -ci4


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

//indent run-equals-input -ldi0


//indent input
void
return_after_rbrace(void)
{
	{}return;
}
//indent end

//indent run
void
return_after_rbrace(void)
{
	{
	}
	return;
}
//indent end