aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/packed-bitfield1.c
blob: b7b575ce6922357833c40b427249f4a0a05c3808 (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
#define __packed	__attribute__((packed))

struct s {
	unsigned int f0:1;
	unsigned int f1:1;
	unsigned int pad:6;
} __packed;
_Static_assert(sizeof(struct s) == 1,  "sizeof(struct s)");

extern struct s g;

static int foo(struct s *ptr)
{
	int f = 0;

	f += g.f0;
	f += g.f1;

	f += ptr->f0;
	f += ptr->f1;

	return f;
}

/*
 * check-name: packed-bitfield1
 */