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: pure virtual functions bug in egcs


> If I have to post this bug once a week until it is fixed, I will do so.

The problem is that nobody puts __pure_virtual into this class, as
mark_vtable_entries is not called. I've copied the relevant part of
it into this patch.

Martin

1998-07-09  Martin von Löwis  <loewis@informatik.hu-berlin.de>

	* class.c (finish_vtbls): Replace pure virtuals with abort_fndecl.

--- /dev/null	Mon Jul 18 01:46:18 1994
+++ g++.other/vtable1.C	Thu Jul  9 09:17:25 1998
@@ -0,0 +1,5 @@
+  class bug {
+  public:
+    virtual void purevirtual()=0;
+  };
+  main() { }

Index: class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/class.c,v
retrieving revision 1.62
diff -c -p -r1.62 class.c
*** class.c	1998/06/17 23:51:39	1.62
--- class.c	1998/07/09 07:12:51
*************** finish_vtbls (binfo, do_self, t)
*** 2199,2205 ****
      {
        if (BINFO_NEW_VTABLE_MARKED (binfo))
  	{
! 	  tree decl, context;
  
  	  decl = BINFO_VTABLE (binfo);
  	  context = DECL_CONTEXT (decl);
--- 2199,2205 ----
      {
        if (BINFO_NEW_VTABLE_MARKED (binfo))
  	{
! 	  tree decl, context,entries;
  
  	  decl = BINFO_VTABLE (binfo);
  	  context = DECL_CONTEXT (decl);
*************** finish_vtbls (binfo, do_self, t)
*** 2208,2213 ****
--- 2208,2229 ----
  	      && DECL_INITIAL (decl) != BINFO_VIRTUALS (binfo))
  	    DECL_INITIAL (decl) = build_nt (CONSTRUCTOR, NULL_TREE,
  					    BINFO_VIRTUALS (binfo));
+           /* Replace pure virtuals with abort_fndecl. */
+ 	  entries = CONSTRUCTOR_ELTS (DECL_INITIAL (decl));
+ 	  skip_rtti_stuff (&entries);
+ 	  for (; entries; entries = TREE_CHAIN (entries))
+             {
+ 	      tree fnaddr = (flag_vtable_thunks ? TREE_VALUE (entries)
+ 	                     : FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (entries)));
+ 	      tree fn = TREE_OPERAND (fnaddr, 0);
+ 	      if (DECL_LANG_SPECIFIC (fn) && DECL_ABSTRACT_VIRTUAL_P (fn))
+ 	        {
+ 		  extern tree abort_fndecl;
+ 		  TREE_OPERAND (fnaddr, 0) = fn = copy_node (fn);
+ 		  DECL_RTL (fn) = DECL_RTL (abort_fndecl);
+ 		  mark_used (abort_fndecl);
+ 		}
+ 	     }
  	  cp_finish_decl (decl, DECL_INITIAL (decl), NULL_TREE, 0, 0);
  	  DECL_CONTEXT (decl) = context;
  	}


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