re PR c++/12053 (ABI difference between default g++ 3.3 and g++ 3.2)
authorMark Mitchell <mark@codesourcery.com>
Wed, 3 Sep 2003 22:00:42 +0000 (22:00 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 3 Sep 2003 22:00:42 +0000 (22:00 +0000)
PR c++/12053
* class.c (include_empty_classes): Correct logic for ABI version 1.

PR c++/12053
* g++.dg/abi/layout4.C: New test.

From-SVN: r71036

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/abi/layout4.C [new file with mode: 0644]

index 4c9a0dae7f590d15f96b0aeb89d9708f7d3ea06a..b64cf992998e73a3fdd2d8751f3a09c780cbc99f 100644 (file)
@@ -1,3 +1,8 @@
+2003-09-03  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/12053
+       * class.c (include_empty_classes): Correct logic for ABI version 1.
+
 2003-09-03  Richard Henderson  <rth@redhat.com>
 
        * optimize.c (optimize_function): Push/pop ggc context around
index 3cf161b1e30109c96fefe0a95235ded2563c8f3f..1bd63cffa6b870c657d63697fa33695026ea4715 100644 (file)
@@ -4586,7 +4586,19 @@ include_empty_classes (record_layout_info rli)
   if (TREE_CODE (rli_size) == INTEGER_CST
       && INT_CST_LT_UNSIGNED (rli_size, eoc))
     {
-      rli->bitpos = round_up (rli->bitpos, BITS_PER_UNIT);
+      if (!abi_version_at_least (2))
+       /* In version 1 of the ABI, the size of a class that ends with
+          a bitfield was not rounded up to a whole multiple of a
+          byte.  Because rli_size_unit_so_far returns only the number
+          of fully allocated bytes, any extra bits were not included
+          in the size.  */
+       rli->bitpos = round_down (rli->bitpos, BITS_PER_UNIT);
+      else
+       /* The size should have been rounded to a whole byte.  */
+       my_friendly_assert (tree_int_cst_equal (rli->bitpos,
+                                               round_down (rli->bitpos,
+                                                           BITS_PER_UNIT)),
+                           20030903);
       rli->bitpos 
        = size_binop (PLUS_EXPR, 
                      rli->bitpos,
index 57b9436a933eabb3b5cfc1fb0e597d77e1fe2e21..a6d708c98fa907e661265a8c755c03f7a064a907 100644 (file)
@@ -1,3 +1,8 @@
+2003-09-03  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/12053
+       * g++.dg/abi/layout4.C: New test.
+
 2003-09-02  Scott Brumbaugh  <scottb.lists@verizon.net>
 
        PR c++/11553
diff --git a/gcc/testsuite/g++.dg/abi/layout4.C b/gcc/testsuite/g++.dg/abi/layout4.C
new file mode 100644 (file)
index 0000000..a1d27ee
--- /dev/null
@@ -0,0 +1,18 @@
+// { dg-do run { target i?86-*-* } }
+// { dg-options "-fabi-version=1" }
+
+struct C4
+{
+   int b:30;
+   C4(){};
+};
+
+struct C1:  virtual C4
+{
+  int i;
+};
+
+int main() {
+  if (sizeof (C1) != 12)
+    return 1;
+}