aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-07-23 17:51:17 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-07-23 13:51:17 -0400
commit7e7760939bf69c764707b32676784af383dacfd4 (patch)
treef1d0eee2a4dfa5cf7f48c34df65351e68eb69a81 /gcc
parent71bca5068d4491157020bdb8a11723787c22f054 (diff)
downloadgcc-7e7760939bf69c764707b32676784af383dacfd4.zip
gcc-7e7760939bf69c764707b32676784af383dacfd4.tar.gz
gcc-7e7760939bf69c764707b32676784af383dacfd4.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl2.c65
3 files changed, 43 insertions, 26 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 06e62e5..e26305e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
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.
(prepare_fresh_vtable): Likewise.
* decl2.c (import_export_class): Split out...
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index b844355..c433e7a 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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_delete_type 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 int finish_prevtable_vardecl PROTO((tree, tree));
extern int walk_vtables PROTO((void (*)(tree, tree),
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 270c2fd..901f565 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -52,7 +52,6 @@ static int cpp_initialized;
static tree get_sentry 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 int finish_vtable_vardecl PROTO((tree, tree));
static int prune_vtable_vardecl PROTO((tree, tree));
@@ -2594,28 +2593,39 @@ import_export_vtable (decl, type, final)
}
}
-static void
-import_export_template (type)
- 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;
- }
-}
+/* Determine whether or not we want to specifically import or export CTYPE,
+ using various heuristics. */
void
import_export_class (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
- 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))
{
tree method;
@@ -2626,15 +2636,19 @@ import_export_class (ctype)
&& !DECL_THIS_INLINE (method)
&& !DECL_ABSTRACT_VIRTUAL_P (method))
{
- SET_CLASSTYPE_INTERFACE_KNOWN (ctype);
- CLASSTYPE_VTABLE_NEEDS_WRITING (ctype)
- = ! DECL_REALLY_EXTERN (method);
- CLASSTYPE_INTERFACE_ONLY (ctype) = DECL_REALLY_EXTERN (method);
+ import_export = (DECL_REALLY_EXTERN (method) ? -1 : 1);
break;
}
}
}
#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
@@ -2833,18 +2847,17 @@ import_export_decl (decl)
{
tree ctype = TREE_TYPE (DECL_NAME (decl));
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
must emit the tinfo function in this translation unit
since it will not be emitted when the vtable for the type
is output (which is when the unqualified version is
generated). */
+ && ctype == TYPE_MAIN_VARIANT (ctype))
+ {
DECL_NOT_REALLY_EXTERN (decl)
- = TYPE_READONLY (ctype)
- || TYPE_VOLATILE (ctype)
- || ! (CLASSTYPE_INTERFACE_ONLY (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
linkonce sections. */