aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/packed-bitfield3.c
diff options
Diffstat (limited to 'validation/packed-bitfield3.c')
-rw-r--r--validation/packed-bitfield3.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/validation/packed-bitfield3.c b/validation/packed-bitfield3.c
new file mode 100644
index 00000000..c06e7c41
--- /dev/null
+++ b/validation/packed-bitfield3.c
@@ -0,0 +1,29 @@
+#define __packed __attribute__((packed))
+
+typedef unsigned char u8;
+typedef __UINT16_TYPE__ u16;
+typedef __UINT32_TYPE__ u32;
+typedef __UINT64_TYPE__ u64;
+
+struct b {
+ u32 a:1;
+ u32 b:2;
+ u32 c:4;
+ u32 d:8;
+ u32 e:16;
+} __packed;
+_Static_assert(__alignof(struct b) == 1);
+_Static_assert( sizeof(struct b) == 4);
+
+struct c {
+ u8 a;
+ u8 b;
+ u64 c:48;
+} __packed;
+_Static_assert(__alignof(struct c) == 1);
+_Static_assert( sizeof(struct c) == 8);
+
+/*
+ * check-name: packed-bitfield3
+ * check-known-to-fail
+ */