This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

C++ PATCH: replace redundant stores with assertions



This patch changes some redundant assignments into assertions, thereby
improving the readability of the snippet in question.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2000-01-16  Mark Mitchell  <mark@codesourcery.com>

	* class.c (finish_struct_1): Replace redundant code with
	assertions.

Index: class.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/class.c,v
retrieving revision 1.235
diff -c -p -r1.235 class.c
*** class.c	2000/01/17 04:07:59	1.235
--- class.c	2000/01/17 05:11:46
*************** finish_struct_1 (t)
*** 4906,4923 ****
  
    if (TYPE_CONTAINS_VPTR_P (t))
      {
        CLASSTYPE_VSIZE (t) = has_virtual;
!       if (CLASSTYPE_HAS_PRIMARY_BASE_P (t))
! 	{
! 	  if (pending_virtuals)
! 	    TYPE_BINFO_VIRTUALS (t) = chainon (TYPE_BINFO_VIRTUALS (t),
! 						pending_virtuals);
! 	}
!       else if (has_virtual)
! 	{
! 	  TYPE_BINFO_VIRTUALS (t) = pending_virtuals;
! 	  DECL_VIRTUAL_P (TYPE_BINFO_VTABLE (t)) = 1;
! 	}
      }
  
    /* Now lay out the virtual function table.  */
--- 4906,4923 ----
  
    if (TYPE_CONTAINS_VPTR_P (t))
      {
+       if (TYPE_BINFO_VTABLE (t))
+ 	my_friendly_assert (DECL_VIRTUAL_P (TYPE_BINFO_VTABLE (t)),
+ 			    20000116);
+       if (!CLASSTYPE_HAS_PRIMARY_BASE_P (t))
+ 	my_friendly_assert (TYPE_BINFO_VIRTUALS (t) == NULL_TREE,
+ 			    20000116);
+ 
        CLASSTYPE_VSIZE (t) = has_virtual;
!       /* Entries for virtual functions defined in the primary base are
! 	 followed by entries for new functions unique to this class.  */
!       TYPE_BINFO_VIRTUALS (t) 
! 	= chainon (TYPE_BINFO_VIRTUALS (t), pending_virtuals);
      }
  
    /* Now lay out the virtual function table.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]