aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/constexpr-conditional.c
blob: 0f2409bf2eae07a0f03663e48df76b03674bc38e (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
static int a[] = {
	[0 ? : 0] = 0,						// OK
	[1 ? : 0] = 0,						// OK
	[0 ? 0 : 0] = 0,					// OK
	[1 ? 0 : 0] = 0,					// OK
	[0 ? 0 : __builtin_choose_expr(0, 0, 0)] = 0,		// OK
	[1 ? __builtin_choose_expr(0, 0, 0) : 0] = 0,		// OK
	[0 ? __builtin_choose_expr(0, 0, 0) : 0] = 0,		// OK
	[1 ? 1 : __builtin_choose_expr(0, 0, 0)] = 0,		// OK
	[__builtin_choose_expr(0, 0, 0) ? : 0] = 0,		// OK
	[__builtin_choose_expr(0, 0, 1) ? : 0] = 0,		// OK
	[0. ? : 0] = 0,					// KO
	[0 ? 0. : 0] = 0,					// KO
	[1 ? : 0.] = 0,					// KO
	[__builtin_choose_expr(0, 0., 0) ? : 0] = 0,		// OK
	[__builtin_choose_expr(0, 0, 0.) ? : 0] = 0,		// KO
	[0 ? __builtin_choose_expr(0, 0., 0) : 0] = 0,		// OK
	[0 ? __builtin_choose_expr(0, 0, 0.) : 0] = 0,		// KO
	[1 ? 0 : __builtin_choose_expr(0, 0., 0)] = 0,		// OK
	[1 ? 0 : __builtin_choose_expr(0, 0, 0.)] = 0,		// KO
};

/*
 * check-name: constexprness in conditionals
 *
 * check-error-start
constexpr-conditional.c:12:13: error: bad constant expression
constexpr-conditional.c:13:19: error: bad constant expression
constexpr-conditional.c:14:12: error: bad constant expression
constexpr-conditional.c:16:42: error: bad constant expression
constexpr-conditional.c:18:48: error: bad constant expression
constexpr-conditional.c:20:14: error: bad constant expression
 * check-error-end
 */