OSDN Git Service

* class.c (layout_class_type): Reuse tail padding when laying out
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 24 Nov 2002 23:26:13 +0000 (23:26 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 24 Nov 2002 23:26:13 +0000 (23:26 +0000)
virtual bases.

* g++.dg/abi/empty10.C: New test.

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

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

index 21d16c0..a2feb54 100644 (file)
@@ -1,3 +1,8 @@
+2002-11-24  Mark Mitchell  <mark@codesourcery.com>
+
+       * class.c (layout_class_type): Reuse tail padding when laying out
+       virtual bases.
+
 2002-11-22  Mark Mitchell  <mark@codesourcery.com>
 
        * rtti.c (qualifier_flags): Fix thinko.
index a36b981..4d54376 100644 (file)
@@ -4993,9 +4993,10 @@ layout_class_type (tree t, tree *virtuals_p)
       normalize_rli (rli);
     }
 
-  /* Make sure that empty classes are reflected in RLI at this 
-     point.  */
-  include_empty_classes(rli);
+  /* G++ 3.2 does not allow virtual bases to be overlaid with tail
+     padding.  */
+  if (!abi_version_at_least (2))
+    include_empty_classes(rli);
 
   /* Delete all zero-width bit-fields from the list of fields.  Now
      that the type is laid out they are no longer important.  */
@@ -5022,8 +5023,17 @@ layout_class_type (tree t, tree *virtuals_p)
        }
       else
        {
-         TYPE_SIZE (base_t) = rli_size_so_far (rli);
-         TYPE_SIZE_UNIT (base_t) = rli_size_unit_so_far (rli);
+         TYPE_SIZE_UNIT (base_t) 
+           = size_binop (MAX_EXPR,
+                         rli_size_unit_so_far (rli),
+                         end_of_class (t, /*include_virtuals_p=*/0));
+         TYPE_SIZE (base_t) 
+           = size_binop (MAX_EXPR,
+                         rli_size_so_far (rli),
+                         size_binop (MULT_EXPR,
+                                     convert (bitsizetype,
+                                              TYPE_SIZE_UNIT (base_t)),
+                                     bitsize_int (BITS_PER_UNIT)));
        }
       TYPE_ALIGN (base_t) = rli->record_align;
       TYPE_USER_ALIGN (base_t) = TYPE_USER_ALIGN (t);
index f6c85f1..c8da992 100644 (file)
@@ -1,3 +1,7 @@
+2002-11-24  Mark Mitchell  <mark@codesourcery.com>
+
+       * g++.dg/abi/empty10.C: New test.
+
 2002-11-24  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.c-torture/compile/20021124-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/abi/empty10.C b/gcc/testsuite/g++.dg/abi/empty10.C
new file mode 100644 (file)
index 0000000..802e2c3
--- /dev/null
@@ -0,0 +1,27 @@
+// { dg-do run }
+// { dg-options "-fabi-version=0 -w" }
+
+struct E {};
+struct E2 : public E {};
+
+struct A {
+  int i;
+};
+
+struct B {
+  int j;
+};
+
+struct C :
+  public E, 
+  public A, 
+  public E2, 
+  virtual public B {
+};
+
+C c;
+
+int main () {
+  if (((char*)(B*)&c - (char*)&c) != 8)
+    return 1;
+}