From 2b34742bf0dbabbdb7335838902323df66974b39 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 27 Apr 2019 20:33:56 -0700 Subject: Unnamed bit-fields don't contribute to size or alignment of unions, or size of structs --- test/bitfield-unnamed-size-align.c | 12 ++++++++++++ test/bitfield-unnamed-size-align.qbe | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 test/bitfield-unnamed-size-align.c create mode 100644 test/bitfield-unnamed-size-align.qbe (limited to 'test') diff --git a/test/bitfield-unnamed-size-align.c b/test/bitfield-unnamed-size-align.c new file mode 100644 index 0000000..505467b --- /dev/null +++ b/test/bitfield-unnamed-size-align.c @@ -0,0 +1,12 @@ +struct s { + int : 8; + char c; +}; +union u { + int : 8; + char c; +}; +int s1 = sizeof(struct s); +int s2 = _Alignof(struct s); +int u1 = sizeof(union u); +int u2 = _Alignof(union u); diff --git a/test/bitfield-unnamed-size-align.qbe b/test/bitfield-unnamed-size-align.qbe new file mode 100644 index 0000000..67dfecc --- /dev/null +++ b/test/bitfield-unnamed-size-align.qbe @@ -0,0 +1,4 @@ +export data $s1 = align 4 { w 2, } +export data $s2 = align 4 { w 1, } +export data $u1 = align 4 { w 1, } +export data $u2 = align 4 { w 1, } -- cgit v1.2.3