rosenberg: handle bit fields better
[smatch.git] / validation / packed-struct.c
blobdad22791060bbefa07ff28ed9954d7af0d7e2b92
1 #define __packed __attribute__((packed))
3 typedef unsigned char u8;
4 typedef __UINT16_TYPE__ u16;
5 typedef __UINT32_TYPE__ u32;
6 typedef __UINT64_TYPE__ u64;
8 struct a {
9 u8 a;
10 u8 b;
11 u16 c;
12 } __packed;
13 _Static_assert(__alignof(struct a) == 1, "align struct");
14 _Static_assert( sizeof(struct a) == 4, " size struct");
16 struct b {
17 u32 a;
18 u32 b;
19 } __packed;
20 _Static_assert(__alignof(struct b) == 1, "align struct");
21 _Static_assert( sizeof(struct b) == 8, "size struct");
23 struct c {
24 u16 a;
25 u32 b;
26 } __packed;
27 _Static_assert(__alignof(struct c) == 1, "align struct");
28 _Static_assert( sizeof(struct c) == 6, "size struct");
31 * check-name: packed-struct