From 3ef20b613c43f71520e20c9a31814b51dc59835d Mon Sep 17 00:00:00 2001 From: mmitchel Date: Wed, 6 Jun 2001 03:15:33 +0000 Subject: [PATCH] * pt.c (instantiate_decl): Tell the repository code about the clones, not the cloned functions. * repo.c (repo_template_used): Explicitly instantiate the cloned function, not the clones. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42931 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/pt.c | 20 +++++++++++++++++++- gcc/cp/repo.c | 8 +++++++- gcc/testsuite/g++.old-deja/g++.pt/repo4.C | 15 +++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/repo4.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f4e08d603f3..7c0ebc5f754 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2001-06-05 Mark Mitchell + + * pt.c (instantiate_decl): Tell the repository code about the + clones, not the cloned functions. + * repo.c (repo_template_used): Explicitly instantiate the cloned + function, not the clones. + 2001-06-05 Nathan Sidwell * call.c (build_user_type_conversion_1): Set ICS_USER_FLAG and diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 19de9614e44..b82ac028f64 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9821,7 +9821,25 @@ instantiate_decl (d, defer_ok) if (pattern_defined) { - repo_template_used (d); + /* Let the repository code that this template definition is + available. + + The repository doesn't need to know about cloned functions + because they never actually show up in the object file. It + does need to know about the clones; those are the symbols + that the linker will be emitting error messages about. */ + if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (d) + || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (d)) + { + tree t; + + for (t = TREE_CHAIN (d); + t && DECL_CLONED_FUNCTION_P (t); + t = TREE_CHAIN (t)) + repo_template_used (t); + } + else + repo_template_used (d); if (flag_external_templates && ! DECL_INTERFACE_KNOWN (d)) { diff --git a/gcc/cp/repo.c b/gcc/cp/repo.c index 6dfcafc24f3..f2f95919d56 100644 --- a/gcc/cp/repo.c +++ b/gcc/cp/repo.c @@ -137,7 +137,13 @@ repo_template_used (t) else if (DECL_P (t)) { if (IDENTIFIER_REPO_CHOSEN (id)) - mark_decl_instantiated (t, 0); + /* It doesn't make sense to instantiate a clone, so we + instantiate the cloned function instead. Note that this + approach will not work correctly if collect2 assigns + different clones to different files -- but it shouldn't. */ + mark_decl_instantiated (DECL_CLONED_FUNCTION_P (t) + ? DECL_CLONED_FUNCTION (t) : t, + 0); } else my_friendly_abort (1); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/repo4.C b/gcc/testsuite/g++.old-deja/g++.pt/repo4.C new file mode 100644 index 00000000000..6180acbb57e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/repo4.C @@ -0,0 +1,15 @@ +// Build then link: +// Special g++ Options: -frepo + +template +struct S { + ~S (); +}; + +template +S::~S () {} + +int main () +{ + S s; +} -- 2.11.4.GIT