aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2003-09-03 22:00:42 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-09-03 22:00:42 +0000
commit43fe31f6f972f1aac0bab077f28363b76c3bfcab (patch)
treea7d94c974540f8282ccd11386e3776d6d9dd3260 /gcc
parent47fe5c480b591d85ddd10b0c5b72f586a16cbeb3 (diff)
downloadgcc-43fe31f6f972f1aac0bab077f28363b76c3bfcab.zip
gcc-43fe31f6f972f1aac0bab077f28363b76c3bfcab.tar.gz
gcc-43fe31f6f972f1aac0bab077f28363b76c3bfcab.tar.bz2
re PR c++/12053 (ABI difference between default g++ 3.3 and g++ 3.2)
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/class.c14
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/abi/layout4.C18
4 files changed, 41 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4c9a0da..b64cf99 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 3cf161b..1bd63cf 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -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,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 57b9436..a6d708c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..a1d27ee
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/layout4.C
@@ -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;
+}