summaryrefslogtreecommitdiff
path: root/tests/usr.bin/indent/fmt_expr.c
blob: d23ebee785ad5678fc12f07c8bec51417919ca8c (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
/* $NetBSD: fmt_expr.c,v 1.10 2023/06/16 23:19:01 rillig Exp $ */

/*
 * Tests for all kinds of expressions that are not directly related to unary
 * or binary operators.
 *
 * See also:
 *	lsym_binary_op.c
 *	lsym_unary_op.c
 */

//indent input
{
	// See lsym_offsetof.c.
	malloc(offsetof(struct s, f) + 1);

	// C99 compound literals use initializer braces.
	println((const char[3]){'-', c, '\0'});
	x = ((struct point){0, 0}).x;

	for (ln = gnodes->first; ln != NULL; ln = ln->next)
		*(GNode **)Vector_Push(&vec) = ln->datum;
}
//indent end

//indent run-equals-input


/*
 * GCC statement expressions are not supported yet.
 */
//indent input
{
	int var = ({1});
	int var = ({
		1
	});
	int var = ({
		int decl = 1;
		stmt;
	});
}
//indent end

//indent run -di0
{
	int var = ({1});
	int var = ({
		   1
		   });
	int var = ({
		   int decl = 1;
		stmt;
	});
}
// exit 1
// error: Standard Input:7: Unbalanced parentheses
// warning: Standard Input:9: Extra ')'
//indent end