diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-05-21 05:42:51 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-05-21 05:42:51 +0000 |
commit | 347cbbaf6097465998ecfe635fa81d9b5c89b9db (patch) | |
tree | 783a6297084b0ebb1575531cfadf2772c291d78a /gcc | |
parent | 8ef8f2b9770aa63238a4679a9618eb2efb2c15b1 (diff) | |
download | gcc-347cbbaf6097465998ecfe635fa81d9b5c89b9db.tar.gz |
* decl2.c (maybe_make_one_only): New fn.
(import_export_vtable): Use it.
(import_export_decl): Likewise.
* pt.c (mark_decl_instantiated): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@19921 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 34 | ||||
-rw-r--r-- | gcc/cp/pt.c | 4 |
3 files changed, 37 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b89b270df3b..b0607c0b592 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +1998-05-21 Jason Merrill <jason@yorick.cygnus.com> + + * decl2.c (maybe_make_one_only): New fn. + (import_export_vtable): Use it. + (import_export_decl): Likewise. + * pt.c (mark_decl_instantiated): Likewise. + 1998-05-21 Mark Mitchell <mmitchell@usa.net> * decl2.c (find_representative_member): Rename to ... diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index a7daa2aafa3..31903411922 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2451,6 +2451,30 @@ comdat_linkage (decl) DECL_COMDAT (decl) = 1; } +/* For win32 we also want to put explicit instantiations in + linkonce sections, so that they will be merged with implicit + instantiations; otherwise we get duplicate symbol errors. */ + +void +maybe_make_one_only (decl) + tree decl; +{ + /* This is not necessary on targets that support weak symbols, because + the implicit instantiations will defer to the explicit one. */ + if (! supports_one_only () || SUPPORTS_WEAK) + return; + + /* We can't set DECL_COMDAT on functions, or finish_file will think + we can get away with not emitting them if they aren't used. + We can't use make_decl_one_only for variables, because their + DECL_INITIAL may not have been set properly yet. */ + + if (TREE_CODE (decl) == FUNCTION_DECL) + make_decl_one_only (decl); + else + comdat_linkage (decl); +} + /* Set TREE_PUBLIC and/or DECL_EXTERN on the vtable DECL, based on TYPE and other static flags. @@ -2481,9 +2505,8 @@ import_export_vtable (decl, type, final) /* For WIN32 we also want to put explicit instantiations in linkonce sections. */ - if (CLASSTYPE_EXPLICIT_INSTANTIATION (type) - && supports_one_only () && ! SUPPORTS_WEAK) - make_decl_one_only (decl); + if (CLASSTYPE_EXPLICIT_INSTANTIATION (type)) + maybe_make_one_only (decl); } else { @@ -2769,9 +2792,8 @@ import_export_decl (decl) /* For WIN32 we also want to put explicit instantiations in linkonce sections. */ - if (CLASSTYPE_EXPLICIT_INSTANTIATION (ctype) - && supports_one_only () && ! SUPPORTS_WEAK) - make_decl_one_only (decl); + if (CLASSTYPE_EXPLICIT_INSTANTIATION (ctype)) + maybe_make_one_only (decl); } else if (TYPE_BUILT_IN (ctype) && ctype == TYPE_MAIN_VARIANT (ctype)) DECL_NOT_REALLY_EXTERN (decl) = 0; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7550271cbb0..2e50cf98109 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6444,8 +6444,8 @@ mark_decl_instantiated (result, extern_p) /* For WIN32 we also want to put explicit instantiations in linkonce sections. */ - if (supports_one_only () && ! SUPPORTS_WEAK && TREE_PUBLIC (result)) - make_decl_one_only (result); + if (TREE_PUBLIC (result)) + maybe_make_one_only (result); } else if (TREE_CODE (result) == FUNCTION_DECL) mark_inline_for_output (result); |