This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: pure virtual functions bug in egcs
- To: leitner at amdiv dot de
- Subject: Re: pure virtual functions bug in egcs
- From: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Thu, 9 Jul 1998 09:23:06 +0200
- CC: egcs-bugs at cygnus dot com
- References: <19980707121532.A16745@amdiv.de>
> 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;
}