fmt_block.c revision 1.5
1/* $NetBSD: fmt_block.c,v 1.5 2023/05/11 09:28:53 rillig Exp $ */
2
3/*
4 * Tests for formatting blocks of statements and declarations.
5 *
6 * See also:
7 *	lsym_lbrace.c
8 *	psym_stmt.c
9 *	psym_stmt_list.c
10 */
11
12//indent input
13void
14function(void)
15{
16	if (true) {
17
18	}
19
20	{
21		print("block");
22	}
23}
24//indent end
25
26//indent run-equals-input
27
28
29/*
30 * Two adjacent blocks must not be merged.  They are typically used in C90 and
31 * earlier to declare local variables with a limited scope.
32 */
33//indent input
34void
35function(void)
36{
37	{}{}
38}
39//indent end
40
41//indent run
42void
43function(void)
44{
45	{
46/* $ FIXME: '{' must start a new line. */
47	} {
48	}
49}
50//indent end
51
52/*
53 * The buggy behavior only occurs with the default setting '-br', which
54 * places an opening brace to the right of the preceding 'if (expr)' or
55 * similar statements.
56 */
57//indent run -bl
58void
59function(void)
60{
61	{
62	}
63	{
64	}
65}
66//indent end
67