aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2004-07-16 09:42:22 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2004-07-16 09:42:22 +0000
commit090ad434b01d10c4c5929816b5912223c39c014a (patch)
tree775bbc4ea3eb5ffad74f598d56aa8d3a17f5f121
parentd811830ea7655b3a2a01f1f5b55c4b0c1083dccf (diff)
downloadgcc-090ad434b01d10c4c5929816b5912223c39c014a.zip
gcc-090ad434b01d10c4c5929816b5912223c39c014a.tar.gz
gcc-090ad434b01d10c4c5929816b5912223c39c014a.tar.bz2
class.c (finish_struct_bits): Use for loop.
* class.c (finish_struct_bits): Use for loop. (propagate_binfo_offsets): Do primary binfo outside of loop. From-SVN: r84815
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/class.c46
2 files changed, 20 insertions, 29 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d8aaf4c..f34b38e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2004-07-16 Nathan Sidwell <nathan@codesourcery.com>
+ * class.c (finish_struct_bits): Use for loop.
+ (propagate_binfo_offsets): Do primary binfo outside of loop.
+
PR c++/16583
* dump.c (cp_dump_tree): Don't dump the bases if there's no
binfo.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 708c1b5..c916d5f 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1414,10 +1414,12 @@ static void
finish_struct_bits (tree t)
{
int n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t));
-
+ tree variants;
+
/* Fix up variants (if any). */
- tree variants = TYPE_NEXT_VARIANT (t);
- while (variants)
+ for (variants = TYPE_NEXT_VARIANT (t);
+ variants;
+ variants = TYPE_NEXT_VARIANT (variants))
{
/* These fields are in the _TYPE part of the node, not in
the TYPE_LANG_SPECIFIC component, so they are not shared. */
@@ -1430,7 +1432,8 @@ finish_struct_bits (tree t)
TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (variants)
= TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (t);
TYPE_POLYMORPHIC_P (variants) = TYPE_POLYMORPHIC_P (t);
- TYPE_USES_VIRTUAL_BASECLASSES (variants) = TYPE_USES_VIRTUAL_BASECLASSES (t);
+ TYPE_USES_VIRTUAL_BASECLASSES (variants)
+ = TYPE_USES_VIRTUAL_BASECLASSES (t);
TYPE_BINFO (variants) = TYPE_BINFO (t);
@@ -1440,8 +1443,6 @@ finish_struct_bits (tree t)
TYPE_FIELDS (variants) = TYPE_FIELDS (t);
TYPE_SIZE (variants) = TYPE_SIZE (t);
TYPE_SIZE_UNIT (variants) = TYPE_SIZE_UNIT (t);
-
- variants = TYPE_NEXT_VARIANT (variants);
}
if (n_baseclasses && TYPE_POLYMORPHIC_P (t))
@@ -4290,33 +4291,20 @@ propagate_binfo_offsets (tree binfo, tree offset)
/* Find the primary base class. */
primary_binfo = get_primary_binfo (binfo);
+ if (primary_binfo && BINFO_PRIMARY_BASE_OF (primary_binfo) == binfo)
+ propagate_binfo_offsets (primary_binfo, offset);
+
/* Scan all of the bases, pushing the BINFO_OFFSET adjust
downwards. */
- for (i = -1; i < BINFO_N_BASE_BINFOS (binfo); ++i)
+ for (i = 0; i < BINFO_N_BASE_BINFOS (binfo); ++i)
{
- tree base_binfo;
-
- /* On the first time through the loop, do the primary base.
- Because the primary base need not be an immediate base, we
- must handle the primary base specially. */
- if (i == -1)
- {
- if (!primary_binfo)
- continue;
-
- base_binfo = primary_binfo;
- }
- else
- {
- base_binfo = BINFO_BASE_BINFO (binfo, i);
- /* Don't do the primary base twice. */
- if (base_binfo == primary_binfo)
- continue;
- }
+ tree base_binfo = BINFO_BASE_BINFO (binfo, i);
+
+ /* Don't do the primary base twice. */
+ if (base_binfo == primary_binfo)
+ continue;
- /* Skip virtual bases that aren't our canonical primary base. */
- if (BINFO_VIRTUAL_P (base_binfo)
- && BINFO_PRIMARY_BASE_OF (base_binfo) != binfo)
+ if (BINFO_VIRTUAL_P (base_binfo))
continue;
propagate_binfo_offsets (base_binfo, offset);