Commit 0f490a2b by Jakub Jelinek Committed by Jakub Jelinek

class.c (layout_virtual_bases): Do all dsize computation on trees.

	* class.c (layout_virtual_bases): Do all dsize computation on trees.

	* g++.dg/other/big-struct.C: New test.

From-SVN: r52304
parent ebef4e8c
2002-04-14 Jakub Jelinek <jakub@redhat.com>
* class.c (layout_virtual_bases): Do all dsize computation on trees.
2002-04-14 Jason Merrill <jason@redhat.com> 2002-04-14 Jason Merrill <jason@redhat.com>
* typeck.c (get_member_function_from_ptrfunc): Don't do * typeck.c (get_member_function_from_ptrfunc): Don't do
......
...@@ -4642,8 +4642,7 @@ layout_virtual_bases (t, offsets) ...@@ -4642,8 +4642,7 @@ layout_virtual_bases (t, offsets)
tree t; tree t;
splay_tree offsets; splay_tree offsets;
{ {
tree vbases; tree vbases, dsize;
unsigned HOST_WIDE_INT dsize;
unsigned HOST_WIDE_INT eoc; unsigned HOST_WIDE_INT eoc;
if (CLASSTYPE_N_BASECLASSES (t) == 0) if (CLASSTYPE_N_BASECLASSES (t) == 0)
...@@ -4656,7 +4655,7 @@ layout_virtual_bases (t, offsets) ...@@ -4656,7 +4655,7 @@ layout_virtual_bases (t, offsets)
#endif #endif
/* DSIZE is the size of the class without the virtual bases. */ /* DSIZE is the size of the class without the virtual bases. */
dsize = tree_low_cst (TYPE_SIZE (t), 1); dsize = TYPE_SIZE (t);
/* Make every class have alignment of at least one. */ /* Make every class have alignment of at least one. */
TYPE_ALIGN (t) = MAX (TYPE_ALIGN (t), BITS_PER_UNIT); TYPE_ALIGN (t) = MAX (TYPE_ALIGN (t), BITS_PER_UNIT);
...@@ -4678,7 +4677,7 @@ layout_virtual_bases (t, offsets) ...@@ -4678,7 +4677,7 @@ layout_virtual_bases (t, offsets)
{ {
/* This virtual base is not a primary base of any class in the /* This virtual base is not a primary base of any class in the
hierarchy, so we have to add space for it. */ hierarchy, so we have to add space for it. */
tree basetype; tree basetype, usize;
unsigned int desired_align; unsigned int desired_align;
basetype = BINFO_TYPE (vbase); basetype = BINFO_TYPE (vbase);
...@@ -4688,19 +4687,21 @@ layout_virtual_bases (t, offsets) ...@@ -4688,19 +4687,21 @@ layout_virtual_bases (t, offsets)
/* Add padding so that we can put the virtual base class at an /* Add padding so that we can put the virtual base class at an
appropriately aligned offset. */ appropriately aligned offset. */
dsize = CEIL (dsize, desired_align) * desired_align; dsize = round_up (dsize, desired_align);
usize = size_binop (CEIL_DIV_EXPR, dsize, bitsize_unit_node);
/* We try to squish empty virtual bases in just like /* We try to squish empty virtual bases in just like
ordinary empty bases. */ ordinary empty bases. */
if (is_empty_class (basetype)) if (is_empty_class (basetype))
layout_empty_base (vbase, layout_empty_base (vbase,
size_int (CEIL (dsize, BITS_PER_UNIT)), convert (sizetype, usize),
offsets, t); offsets, t);
else else
{ {
tree offset; tree offset;
offset = ssize_int (CEIL (dsize, BITS_PER_UNIT)); offset = convert (ssizetype, usize);
offset = size_diffop (offset, offset = size_diffop (offset,
convert (ssizetype, convert (ssizetype,
BINFO_OFFSET (vbase))); BINFO_OFFSET (vbase)));
...@@ -4710,8 +4711,9 @@ layout_virtual_bases (t, offsets) ...@@ -4710,8 +4711,9 @@ layout_virtual_bases (t, offsets)
/* Every virtual baseclass takes a least a UNIT, so that /* Every virtual baseclass takes a least a UNIT, so that
we can take it's address and get something different we can take it's address and get something different
for each base. */ for each base. */
dsize += MAX (BITS_PER_UNIT, dsize = size_binop (PLUS_EXPR, dsize,
tree_low_cst (CLASSTYPE_SIZE (basetype), 0)); size_binop (MAX_EXPR, bitsize_unit_node,
CLASSTYPE_SIZE (basetype)));
} }
/* Keep track of the offsets assigned to this virtual base. */ /* Keep track of the offsets assigned to this virtual base. */
...@@ -4733,13 +4735,12 @@ layout_virtual_bases (t, offsets) ...@@ -4733,13 +4735,12 @@ layout_virtual_bases (t, offsets)
class, we didn't update DSIZE above; we were hoping to overlay class, we didn't update DSIZE above; we were hoping to overlay
multiple such bases at the same location. */ multiple such bases at the same location. */
eoc = end_of_class (t, /*include_virtuals_p=*/1); eoc = end_of_class (t, /*include_virtuals_p=*/1);
if (eoc * BITS_PER_UNIT > dsize) dsize = size_binop (MAX_EXPR, dsize, bitsize_int (eoc * BITS_PER_UNIT));
dsize = eoc * BITS_PER_UNIT;
/* Now, make sure that the total size of the type is a multiple of /* Now, make sure that the total size of the type is a multiple of
its alignment. */ its alignment. */
dsize = CEIL (dsize, TYPE_ALIGN (t)) * TYPE_ALIGN (t); dsize = round_up (dsize, TYPE_ALIGN (t));
TYPE_SIZE (t) = bitsize_int (dsize); TYPE_SIZE (t) = dsize;
TYPE_SIZE_UNIT (t) = convert (sizetype, TYPE_SIZE_UNIT (t) = convert (sizetype,
size_binop (CEIL_DIV_EXPR, TYPE_SIZE (t), size_binop (CEIL_DIV_EXPR, TYPE_SIZE (t),
bitsize_unit_node)); bitsize_unit_node));
......
2002-04-14 Jakub Jelinek <jakub@redhat.com>
* g++.dg/other/big-struct.C: New test.
2002-04-14 David Billinghurst <David.Billinghurst@riotinto.com> 2002-04-14 David Billinghurst <David.Billinghurst@riotinto.com>
* g77.dg/f77-edit-i-in.f: Use internal buffer in place * g77.dg/f77-edit-i-in.f: Use internal buffer in place
......
// { dg-do compile { target i?86-*-* } }
struct A
{
};
struct B : public A
{
char b[0x20000000];
} e;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment