aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/constexpr-addr-of-static-member.c
blob: c2a74ac78b9e210ce4df84e3c51de7180dac1608 (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
struct A {
	int a;
	int b[2];
};

struct B {
	int c;
	struct A d;
};

static struct B a= {1, {1, {1, 1}}};

static int *b = &a.d.a;	// OK
static int *c = &(&a.d)->a;	// OK
static int *d = a.d.b;		// OK
static int *e = (&a.d)->b;	// OK
static int *f = &a.d.b[1];	// OK
static int *g = &(&a.d)->b[1];	// OK

/*
 * check-name: constexpr static object's member address
 * check-command: sparse -Wconstexpr-not-const $file
 *
 * check-error-start
 * check-error-end
 */