aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2002-11-24 23:26:13 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2002-11-24 23:26:13 +0000
commit8a874cb4375959c5653959372507fd980fad7957 (patch)
tree86d3041c59c15d3b3a525c0b70a8d5c24a779764
parentadde288a90bb507dd7dccc6cdc46bf8ec0546a49 (diff)
downloadgcc-8a874cb4375959c5653959372507fd980fad7957.zip
gcc-8a874cb4375959c5653959372507fd980fad7957.tar.gz
gcc-8a874cb4375959c5653959372507fd980fad7957.tar.bz2
class.c (layout_class_type): Reuse tail padding when laying out virtual bases.
* class.c (layout_class_type): Reuse tail padding when laying out virtual bases. * g++.dg/abi/empty10.C: New test. From-SVN: r59443
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/class.c20
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/abi/empty10.C27
4 files changed, 51 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 21d16c0..a2feb54 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index a36b981..4d54376 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f6c85f1..c8da992 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..802e2c3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/empty10.C
@@ -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;
+}