Commit 7e776093 by Jason Merrill Committed by Jason Merrill

decl2.c (import_export_template): Fold in...

	* decl2.c (import_export_template): Fold in...
	(import_export_class): ...to here.  Handle dllimport/export.

From-SVN: r21350
parent 71bca506
1998-07-23 Jason Merrill <jason@yorick.cygnus.com> 1998-07-23 Jason Merrill <jason@yorick.cygnus.com>
* decl2.c (import_export_template): Fold in...
(import_export_class): ...to here. Handle dllimport/export.
* class.c (build_vtable): Pass at_eof to import_export_vtable. * class.c (build_vtable): Pass at_eof to import_export_vtable.
(prepare_fresh_vtable): Likewise. (prepare_fresh_vtable): Likewise.
* decl2.c (import_export_class): Split out... * decl2.c (import_export_class): Split out...
......
...@@ -2485,6 +2485,7 @@ extern void finish_builtin_type PROTO((tree, char *, tree *, int, tree)); ...@@ -2485,6 +2485,7 @@ extern void finish_builtin_type PROTO((tree, char *, tree *, int, tree));
extern tree coerce_new_type PROTO((tree)); extern tree coerce_new_type PROTO((tree));
extern tree coerce_delete_type PROTO((tree)); extern tree coerce_delete_type PROTO((tree));
extern void comdat_linkage PROTO((tree)); extern void comdat_linkage PROTO((tree));
extern void import_export_class PROTO((tree));
extern void import_export_vtable PROTO((tree, tree, int)); extern void import_export_vtable PROTO((tree, tree, int));
extern int finish_prevtable_vardecl PROTO((tree, tree)); extern int finish_prevtable_vardecl PROTO((tree, tree));
extern int walk_vtables PROTO((void (*)(tree, tree), extern int walk_vtables PROTO((void (*)(tree, tree),
......
...@@ -52,7 +52,6 @@ static int cpp_initialized; ...@@ -52,7 +52,6 @@ static int cpp_initialized;
static tree get_sentry PROTO((tree)); static tree get_sentry PROTO((tree));
static void mark_vtable_entries PROTO((tree)); static void mark_vtable_entries PROTO((tree));
static void import_export_template PROTO((tree));
static void grok_function_init PROTO((tree, tree)); static void grok_function_init PROTO((tree, tree));
static int finish_vtable_vardecl PROTO((tree, tree)); static int finish_vtable_vardecl PROTO((tree, tree));
static int prune_vtable_vardecl PROTO((tree, tree)); static int prune_vtable_vardecl PROTO((tree, tree));
...@@ -2594,28 +2593,39 @@ import_export_vtable (decl, type, final) ...@@ -2594,28 +2593,39 @@ import_export_vtable (decl, type, final)
} }
} }
static void /* Determine whether or not we want to specifically import or export CTYPE,
import_export_template (type) using various heuristics. */
tree type;
{
if (CLASSTYPE_IMPLICIT_INSTANTIATION (type)
&& ! flag_implicit_templates
&& CLASSTYPE_INTERFACE_UNKNOWN (type))
{
SET_CLASSTYPE_INTERFACE_KNOWN (type);
CLASSTYPE_INTERFACE_ONLY (type) = 1;
CLASSTYPE_VTABLE_NEEDS_WRITING (type) = 0;
}
}
void void
import_export_class (ctype) import_export_class (ctype)
tree ctype; tree ctype;
{ {
import_export_template (ctype); /* -1 for imported, 1 for exported. */
int import_export = 0;
if (CLASSTYPE_INTERFACE_KNOWN (ctype))
return;
#ifdef VALID_MACHINE_TYPE_ATTRIBUTE
/* FIXME this should really use some sort of target-independent macro. */
if (lookup_attribute ("dllimport", TYPE_ATTRIBUTES (ctype)))
import_export = -1;
else if (lookup_attribute ("dllexport", TYPE_ATTRIBUTES (ctype)))
import_export = 1;
#endif
/* If we got -fno-implicit-templates, we import template classes that
weren't explicitly instantiated. */
if (import_export == 0
&& CLASSTYPE_IMPLICIT_INSTANTIATION (ctype)
&& ! flag_implicit_templates)
import_export = -1;
#ifndef MULTIPLE_SYMBOL_SPACES #ifndef MULTIPLE_SYMBOL_SPACES
if (CLASSTYPE_INTERFACE_UNKNOWN (ctype) && TYPE_VIRTUAL_P (ctype) /* Base our import/export status on that of the first non-inline,
non-abstract virtual function, if any. */
if (import_export == 0
&& TYPE_VIRTUAL_P (ctype)
&& ! CLASSTYPE_TEMPLATE_INSTANTIATION (ctype)) && ! CLASSTYPE_TEMPLATE_INSTANTIATION (ctype))
{ {
tree method; tree method;
...@@ -2626,15 +2636,19 @@ import_export_class (ctype) ...@@ -2626,15 +2636,19 @@ import_export_class (ctype)
&& !DECL_THIS_INLINE (method) && !DECL_THIS_INLINE (method)
&& !DECL_ABSTRACT_VIRTUAL_P (method)) && !DECL_ABSTRACT_VIRTUAL_P (method))
{ {
SET_CLASSTYPE_INTERFACE_KNOWN (ctype); import_export = (DECL_REALLY_EXTERN (method) ? -1 : 1);
CLASSTYPE_VTABLE_NEEDS_WRITING (ctype)
= ! DECL_REALLY_EXTERN (method);
CLASSTYPE_INTERFACE_ONLY (ctype) = DECL_REALLY_EXTERN (method);
break; break;
} }
} }
} }
#endif #endif
if (import_export)
{
SET_CLASSTYPE_INTERFACE_KNOWN (ctype);
CLASSTYPE_VTABLE_NEEDS_WRITING (ctype) = (import_export > 0);
CLASSTYPE_INTERFACE_ONLY (ctype) = (import_export < 0);
}
} }
int int
...@@ -2833,18 +2847,17 @@ import_export_decl (decl) ...@@ -2833,18 +2847,17 @@ import_export_decl (decl)
{ {
tree ctype = TREE_TYPE (DECL_NAME (decl)); tree ctype = TREE_TYPE (DECL_NAME (decl));
if (IS_AGGR_TYPE (ctype) && CLASSTYPE_INTERFACE_KNOWN (ctype) if (IS_AGGR_TYPE (ctype) && CLASSTYPE_INTERFACE_KNOWN (ctype)
&& TYPE_VIRTUAL_P (ctype)) && TYPE_VIRTUAL_P (ctype)
{
/* If the type is a cv-qualified variant of a type, then we /* If the type is a cv-qualified variant of a type, then we
must emit the tinfo function in this translation unit must emit the tinfo function in this translation unit
since it will not be emitted when the vtable for the type since it will not be emitted when the vtable for the type
is output (which is when the unqualified version is is output (which is when the unqualified version is
generated). */ generated). */
&& ctype == TYPE_MAIN_VARIANT (ctype))
{
DECL_NOT_REALLY_EXTERN (decl) DECL_NOT_REALLY_EXTERN (decl)
= TYPE_READONLY (ctype) = ! (CLASSTYPE_INTERFACE_ONLY (ctype)
|| TYPE_VOLATILE (ctype) || (DECL_THIS_INLINE (decl) && ! flag_implement_inlines));
|| ! (CLASSTYPE_INTERFACE_ONLY (ctype)
|| (DECL_THIS_INLINE (decl) && ! flag_implement_inlines));
/* For WIN32 we also want to put explicit instantiations in /* For WIN32 we also want to put explicit instantiations in
linkonce sections. */ linkonce sections. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment