This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Simplify some code
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 16 Jul 2004 10:43:04 +0100
- Subject: [C++ PATCH] Simplify some code
- Organization: Codesourcery LLC
This patch removes a special case from one loop, and cleans up another loop.
built & tested on i686-pc-linux-gnu, installed
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
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.
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.635
diff -c -3 -p -r1.635 class.c
*** cp/class.c 16 Jul 2004 01:15:33 -0000 1.635
--- cp/class.c 16 Jul 2004 09:30:15 -0000
*************** static void
*** 1414,1423 ****
finish_struct_bits (tree t)
{
int n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t));
!
/* Fix up variants (if any). */
! tree variants = TYPE_NEXT_VARIANT (t);
! while (variants)
{
/* These fields are in the _TYPE part of the node, not in
the TYPE_LANG_SPECIFIC component, so they are not shared. */
--- 1414,1425 ----
finish_struct_bits (tree t)
{
int n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t));
! tree variants;
!
/* Fix up variants (if any). */
! 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. */
*************** finish_struct_bits (tree t)
*** 1430,1436 ****
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_BINFO (variants) = TYPE_BINFO (t);
--- 1432,1439 ----
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_BINFO (variants) = TYPE_BINFO (t);
*************** finish_struct_bits (tree t)
*** 1440,1447 ****
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))
--- 1443,1448 ----
*************** propagate_binfo_offsets (tree binfo, tre
*** 4290,4322 ****
/* Find the primary base class. */
primary_binfo = get_primary_binfo (binfo);
/* Scan all of the bases, pushing the BINFO_OFFSET adjust
downwards. */
! for (i = -1; 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;
! }
! /* Skip virtual bases that aren't our canonical primary base. */
! if (BINFO_VIRTUAL_P (base_binfo)
! && BINFO_PRIMARY_BASE_OF (base_binfo) != binfo)
continue;
propagate_binfo_offsets (base_binfo, offset);
--- 4291,4310 ----
/* 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 = 0; i < BINFO_N_BASE_BINFOS (binfo); ++i)
{
! tree base_binfo = BINFO_BASE_BINFO (binfo, i);
!
! /* Don't do the primary base twice. */
! if (base_binfo == primary_binfo)
! continue;
! if (BINFO_VIRTUAL_P (base_binfo))
continue;
propagate_binfo_offsets (base_binfo, offset);