OSDN Git Service

PR c++/9704
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Feb 2003 19:17:29 +0000 (19:17 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Feb 2003 19:17:29 +0000 (19:17 +0000)
* class.c (layout_class_type): In the 3.2 ABI, take into account
trailing bit fields when computing CLASSTYPE_SIZE_UNIT.

PR c++/9704
* g++.dg/init/copy5.C: New test.

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

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog

index 73676fc..9071de0 100644 (file)
@@ -1,3 +1,9 @@
+2003-02-18  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/9704
+       * class.c (layout_class_type): In the 3.2 ABI, take into account
+       trailing bit fields when computing CLASSTYPE_SIZE_UNIT.
+
 2003-02-18  Matt Austern <austern@apple.com>
        
        * cp/cp-lang.c: Change lang hooks so that final_write_globals does
index 5e8b9fa..5ee67bc 100644 (file)
@@ -5194,16 +5194,28 @@ layout_class_type (tree t, tree *virtuals_p)
        }
       else
        {
+         tree eoc;
+
+         /* If the ABI version is not at least two, and the last
+            field was a bit-field, RLI may not be on a byte
+            boundary.  In particular, rli_size_unit_so_far might
+            indicate the last complete byte, while rli_size_so_far
+            indicates the total number of bits used.  Therefore,
+            rli_size_so_far, rather than rli_size_unit_so_far, is
+            used to compute TYPE_SIZE_UNIT.  */
+         eoc = end_of_class (t, /*include_virtuals_p=*/0);
          TYPE_SIZE_UNIT (base_t) 
            = size_binop (MAX_EXPR,
-                         rli_size_unit_so_far (rli),
-                         end_of_class (t, /*include_virtuals_p=*/0));
+                         convert (sizetype,
+                                  size_binop (CEIL_DIV_EXPR,
+                                              rli_size_so_far (rli),
+                                              bitsize_int (BITS_PER_UNIT))),
+                         eoc);
          TYPE_SIZE (base_t) 
            = size_binop (MAX_EXPR,
                          rli_size_so_far (rli),
                          size_binop (MULT_EXPR,
-                                     convert (bitsizetype,
-                                              TYPE_SIZE_UNIT (base_t)),
+                                     convert (bitsizetype, eoc),
                                      bitsize_int (BITS_PER_UNIT)));
        }
       TYPE_ALIGN (base_t) = rli->record_align;
index 96d1b06..220c696 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-18  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/9704
+       * g++.dg/init/copy5.C: New test.
+       
 2003-02-18  Geoffrey Keating  <geoffk@apple.com>
 
        * gcc.dg/pch/pch.exp: Delete $bname.h before copying into it.