This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
(C++) vtable linkage patch
- To: egcs-patches at cygnus dot com
- Subject: (C++) vtable linkage patch
- From: Jason Merrill <jason at cygnus dot com>
- Date: Wed, 28 Oct 1998 20:20:41 -0800
Yes, kids, it's time for the latest installment in the long-running saga of
trying to get vtable linkage right! We were calling repo_template_used
after we had already decided not to emit the vtable for a class. This
patch simplifies things by delaying the decision until the last minute.
Fixes g++.pt/instantiate4.C. Applied.
1998-10-28 Jason Merrill <jason@yorick.cygnus.com>
* class.c (build_vtable): Don't pass at_eof to import_export_vtable.
(prepare_fresh_vtable): Likewise.
(finish_struct_1): Don't call import_export_class.
* decl2.c (finish_vtable_vardecl): Do import/export stuff.
(finish_prevtable_vardecl): Lose.
(finish_file): Don't call it.
* pt.c (instantiate_class_template): Likewise.
Index: class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/class.c,v
retrieving revision 1.101
diff -c -p -r1.101 class.c
*** class.c 1998/10/28 01:53:43 1.101
--- class.c 1998/10/29 04:14:28
*************** build_vtable (binfo, type)
*** 717,723 ****
#endif
/* Set TREE_PUBLIC and TREE_EXTERN as appropriate. */
! import_export_vtable (decl, type, at_eof);
decl = pushdecl_top_level (decl);
SET_IDENTIFIER_GLOBAL_VALUE (name, decl);
--- 717,723 ----
#endif
/* Set TREE_PUBLIC and TREE_EXTERN as appropriate. */
! import_export_vtable (decl, type, 0);
decl = pushdecl_top_level (decl);
SET_IDENTIFIER_GLOBAL_VALUE (name, decl);
*************** prepare_fresh_vtable (binfo, for_type)
*** 901,907 ****
#endif
/* Set TREE_PUBLIC and TREE_EXTERN as appropriate. */
! import_export_vtable (new_decl, for_type, at_eof);
if (TREE_VIA_VIRTUAL (binfo))
my_friendly_assert (binfo == binfo_member (BINFO_TYPE (binfo),
--- 901,907 ----
#endif
/* Set TREE_PUBLIC and TREE_EXTERN as appropriate. */
! import_export_vtable (new_decl, for_type, 0);
if (TREE_VIA_VIRTUAL (binfo))
my_friendly_assert (binfo == binfo_member (BINFO_TYPE (binfo),
*************** finish_struct_1 (t, warn_anon)
*** 4042,4052 ****
max_has_virtual = has_virtual;
if (max_has_virtual > 0)
TYPE_VIRTUAL_P (t) = 1;
-
- /* Do this here before we start messing with vtables so that we are ready
- for import_export_vtable. */
- if (at_eof)
- import_export_class (t);
if (flag_rtti && TYPE_VIRTUAL_P (t) && !pending_hard_virtuals)
modify_all_vtables (t, NULL_TREE, NULL_TREE);
--- 4042,4047 ----
Index: decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.150
diff -c -p -r1.150 decl2.c
*** decl2.c 1998/10/28 01:53:46 1.150
--- decl2.c 1998/10/29 04:14:29
*************** import_export_class (ctype)
*** 2578,2593 ****
}
}
- int
- finish_prevtable_vardecl (prev, vars)
- tree prev ATTRIBUTE_UNUSED, vars;
- {
- tree ctype = DECL_CONTEXT (vars);
- import_export_class (ctype);
- import_export_vtable (vars, ctype, 1);
- return 1;
- }
-
/* We need to describe to the assembler the relationship between
a vtable and the vtable of the parent class. */
--- 2578,2583 ----
*************** static int
*** 2619,2624 ****
--- 2609,2618 ----
finish_vtable_vardecl (prev, vars)
tree prev, vars;
{
+ tree ctype = DECL_CONTEXT (vars);
+ import_export_class (ctype);
+ import_export_vtable (vars, ctype, 1);
+
if (! DECL_EXTERNAL (vars)
&& (DECL_INTERFACE_KNOWN (vars)
|| TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (vars))
*************** finish_file ()
*** 3351,3361 ****
SET_DECL_ARTIFICIAL (vars);
pushdecl (vars);
#endif
-
- /* Walk to mark the inline functions we need, then output them so
- that we can pick up any other tdecls that those routines need. */
- walk_vtables ((void (*) PROTO ((tree, tree))) 0,
- finish_prevtable_vardecl);
for (vars = static_aggregates; vars; vars = TREE_CHAIN (vars))
if (! TREE_ASM_WRITTEN (TREE_VALUE (vars)))
--- 3345,3350 ----
Index: pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.224
diff -c -p -r1.224 pt.c
*** pt.c 1998/10/28 11:46:03 1.224
--- pt.c 1998/10/29 04:14:29
*************** instantiate_class_template (type)
*** 4736,4743 ****
CLASSTYPE_GOT_SEMICOLON (type) = 1;
repo_template_used (type);
- if (at_eof && TYPE_BINFO_VTABLE (type) != NULL_TREE)
- finish_prevtable_vardecl (NULL, TYPE_BINFO_VTABLE (type));
end:
TYPE_BEING_DEFINED (type) = 0;
--- 4736,4741 ----