aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/constexpr-compound-literal.c
blob: e137873955bc3369ca83c33e7aa87728fa554472 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
static int *a = &(int){ 1 };	// OK
static int *b = &(int){ *a };	// KO

static void foo(void)
{
	int *b = &(int){ 1 };		// OK
	int *c = &(int){ *a };		// OK
	static int *d = &(int){ 1 };	// KO
}

/*
 * check-name: constexpr compound literal address
 * check-command: sparse -Wconstexpr-not-const $file
 *
 * check-error-start
constexpr-compound-literal.c:2:25: warning: non-constant initializer for static object
constexpr-compound-literal.c:8:27: warning: non-constant initializer for static object
 * check-error-end
 */