This is the mail archive of the gcc-bugs@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]

Re: strange virtual functions bug (was: (none))


Jeff, this can go into the release.

>>>>> Miloslav GRUNDMANN <grundman@mip.ups-tlse.fr> writes:

> //
> // This is an old bug that has not been resolved yet
> //
> //
> // This is really a strange bug, I was unable to focus it better
> // gcc version  egcs-2.90.18 971122 (gcc2-970802 experimental)
> // alpha-dec-osf4.0a
> // there is something wrong in virtual functions
> //

Thu Nov 27 00:59:46 1997  Jason Merrill  <jason@yorick.cygnus.com>

	* class.c: Remove static pending_hard_virtuals.
 	(add_virtual_function): Take pointers to pending_virtuals
	and pending_hard_virtuals.
	(finish_struct_1): Pass them.  Declare pending_hard_virtuals.

Index: class.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/cp/class.c,v
retrieving revision 1.286
diff -c -r1.286 class.c
*** class.c	1997/11/02 23:07:31	1.286
--- class.c	1997/11/27 08:59:31
***************
*** 103,109 ****
  static void finish_vtbls PROTO((tree, int, tree));
  static void modify_vtable_entry PROTO((tree, tree, tree));
  static tree get_vtable_entry_n PROTO((tree, unsigned HOST_WIDE_INT));
! static tree add_virtual_function PROTO((tree, int *, tree, tree));
  static tree delete_duplicate_fields_1 PROTO((tree, tree));
  static void delete_duplicate_fields PROTO((tree));
  static void finish_struct_bits PROTO((tree, int));
--- 103,109 ----
  static void finish_vtbls PROTO((tree, int, tree));
  static void modify_vtable_entry PROTO((tree, tree, tree));
  static tree get_vtable_entry_n PROTO((tree, unsigned HOST_WIDE_INT));
! static void add_virtual_function PROTO((tree *, tree *, int *, tree, tree));
  static tree delete_duplicate_fields_1 PROTO((tree, tree));
  static void delete_duplicate_fields PROTO((tree));
  static void finish_struct_bits PROTO((tree, int));
***************
*** 416,426 ****
  
  /* Virtual function things.  */
  
- /* Virtual functions to be dealt with after laying out our base
-    classes.  We do all overrides after we layout virtual base classes.  */
- 
- static tree pending_hard_virtuals;
- 
  /* Build an entry in the virtual function table.
     DELTA is the offset for the `this' pointer.
     PFN is an ADDR_EXPR containing a pointer to the virtual function.
--- 416,421 ----
***************
*** 953,965 ****
     vtable for the type, and we build upon the PENDING_VIRTUALS list
     and return it.  */
  
! static tree
! add_virtual_function (pending_virtuals, has_virtual, fndecl, t)
!      tree pending_virtuals;
       int *has_virtual;
       tree fndecl;
       tree t; /* Structure type.  */
  {
    /* FUNCTION_TYPEs and OFFSET_TYPEs no longer freely
       convert to void *.  Make such a conversion here.  */
    tree vfn = build1 (ADDR_EXPR, vfunc_ptr_type_node, fndecl);
--- 948,963 ----
     vtable for the type, and we build upon the PENDING_VIRTUALS list
     and return it.  */
  
! static void
! add_virtual_function (pv, phv, has_virtual, fndecl, t)
!      tree *pv, *phv;
       int *has_virtual;
       tree fndecl;
       tree t; /* Structure type.  */
  {
+   tree pending_virtuals = *pv;
+   tree pending_hard_virtuals = *phv;
+ 
    /* FUNCTION_TYPEs and OFFSET_TYPEs no longer freely
       convert to void *.  Make such a conversion here.  */
    tree vfn = build1 (ADDR_EXPR, vfunc_ptr_type_node, fndecl);
***************
*** 1023,1029 ****
           Deal with this after we have laid out our virtual base classes.  */
        pending_hard_virtuals = temp_tree_cons (fndecl, vfn, pending_hard_virtuals);
      }
!   return pending_virtuals;
  }
  
  /* Obstack on which to build the vector of class methods.  */
--- 1021,1028 ----
           Deal with this after we have laid out our virtual base classes.  */
        pending_hard_virtuals = temp_tree_cons (fndecl, vfn, pending_hard_virtuals);
      }
!   *pv = pending_virtuals;
!   *phv = pending_hard_virtuals;
  }
  
  /* Obstack on which to build the vector of class methods.  */
***************
*** 3109,3114 ****
--- 3108,3114 ----
    int has_virtual;
    int max_has_virtual;
    tree pending_virtuals = NULL_TREE;
+   tree pending_hard_virtuals = NULL_TREE;
    tree abstract_virtuals = NULL_TREE;
    tree vfield;
    tree vfields;
***************
*** 3275,3282 ****
        if (DECL_VINDEX (x)
  	  || (all_virtual == 1 && ! DECL_CONSTRUCTOR_P (x)))
  	{
! 	  pending_virtuals = add_virtual_function (pending_virtuals,
! 						   &has_virtual, x, t);
  	  if (DECL_ABSTRACT_VIRTUAL_P (x))
  	    abstract_virtuals = tree_cons (NULL_TREE, x, abstract_virtuals);
  #if 0
--- 3275,3282 ----
        if (DECL_VINDEX (x)
  	  || (all_virtual == 1 && ! DECL_CONSTRUCTOR_P (x)))
  	{
! 	  add_virtual_function (&pending_virtuals, &pending_hard_virtuals,
! 				&has_virtual, x, t);
  	  if (DECL_ABSTRACT_VIRTUAL_P (x))
  	    abstract_virtuals = tree_cons (NULL_TREE, x, abstract_virtuals);
  #if 0
***************
*** 3663,3670 ****
  	  fn_fields = dtor;
  
  	  if (DECL_VINDEX (dtor))
! 	    pending_virtuals = add_virtual_function (pending_virtuals,
! 						     &has_virtual, dtor, t);
  	  nonprivate_method = 1;
  	}
      }
--- 3663,3670 ----
  	  fn_fields = dtor;
  
  	  if (DECL_VINDEX (dtor))
! 	    add_virtual_function (&pending_virtuals, &pending_hard_virtuals,
! 				  &has_virtual, dtor, t);
  	  nonprivate_method = 1;
  	}
      }


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