From: Jason Merrill Date: Tue, 14 Oct 2003 18:43:27 +0000 (-0400) Subject: stor-layout.c (do_type_align): New fn, split out from... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b4d5fde31787e652ca03dcd9143911d34eab136;p=platform%2Fupstream%2Fgcc.git stor-layout.c (do_type_align): New fn, split out from... * stor-layout.c (do_type_align): New fn, split out from... (layout_decl): ...here. Do all alignment calculations for FIELD_DECLs here. (update_alignment_for_field): Not here. (start_record_layout, debug_rli): Remove unpadded_align. * tree.h (struct record_layout_info_s): Remove unpadded_align. * c-decl.c (finish_enum): Don't set DECL_SIZE, DECL_ALIGN or DECL_MODE on the CONST_DECLs. (finish_struct): Don't mess with DECL_ALIGN. From-SVN: r72485 --- diff --git a/gcc/testsuite/gcc.dg/pack-test-4.c b/gcc/testsuite/gcc.dg/pack-test-4.c new file mode 100644 index 0000000..e0cfdf7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pack-test-4.c @@ -0,0 +1,32 @@ +// PR c/11885 +// Bug: flag4 was allocated into the same byte as the other flags. +// { dg-do run } + +typedef unsigned char uint8_t; + +typedef struct { + + uint8_t flag1:2; + uint8_t flag2:1; + uint8_t flag3:1; + + uint8_t flag4; + +} __attribute__ ((packed)) MyType; + +int main (void) +{ + MyType a; + MyType *b = &a; + + b->flag1 = 0; + b->flag2 = 0; + b->flag3 = 0; + + b->flag4 = 0; + + b->flag4++; + + if (b->flag1 != 0) + abort (); +}