OSDN Git Service

* stor-layout.c (do_type_align): New fn, split out from...
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Oct 2003 18:43:27 +0000 (18:43 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Oct 2003 18:43:27 +0000 (18:43 +0000)
        (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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72485 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/gcc.dg/pack-test-4.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/pack-test-4.c b/gcc/testsuite/gcc.dg/pack-test-4.c
new file mode 100644 (file)
index 0000000..e0cfdf7
--- /dev/null
@@ -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 ();
+}