diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-04-07 15:54:42 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-04-07 15:54:42 +0000 |
commit | 90fb08fc73be441f9af09ad8ca93b6d837bc4dcf (patch) | |
tree | cff0e08f71b364fc0ce4649355d0bef0429f0ea4 | |
parent | a9f5259f080a1c114a6de06f2ec67730e4e50f13 (diff) | |
download | gcc-90fb08fc73be441f9af09ad8ca93b6d837bc4dcf.tar.gz |
PR c++/38392
* pt.c (tsubst_friend_function): Instatiate a friend that has already
been used.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158073 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/friend51.C | 17 |
4 files changed, 36 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d3b0788218d..6e048cad8b9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2010-04-07 Jason Merrill <jason@redhat.com> + PR c++/38392 + * pt.c (tsubst_friend_function): Instatiate a friend that has already + been used. + * pt.c (print_template_statistics): New. * cp-tree.h: Declare it. * tree.c (cxx_print_statistics): Call it. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d1c33d65277..1c0e13ea4dc 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7330,11 +7330,18 @@ tsubst_friend_function (tree decl, tree args) DECL_TEMPLATE_INFO (old_decl) = new_friend_template_info; if (TREE_CODE (old_decl) != TEMPLATE_DECL) - /* We should have called reregister_specialization in - duplicate_decls. */ - gcc_assert (retrieve_specialization (new_template, - new_args, 0) - == old_decl); + { + /* We should have called reregister_specialization in + duplicate_decls. */ + gcc_assert (retrieve_specialization (new_template, + new_args, 0) + == old_decl); + + /* Instantiate it if the global has already been used. */ + if (DECL_ODR_USED (old_decl)) + instantiate_decl (old_decl, /*defer_ok=*/true, + /*expl_inst_class_mem_p=*/false); + } else { tree t; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3138c8a3d1c..3df0787cc8b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2010-04-07 Jason Merrill <jason@redhat.com> + PR c++/38392 + * g++.dg/template/friend51.C: New test. + PR c++/41970 * g++.old-deja/g++.other/linkage1.C: Adjust. diff --git a/gcc/testsuite/g++.dg/template/friend51.C b/gcc/testsuite/g++.dg/template/friend51.C new file mode 100644 index 00000000000..d2d1ad799d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend51.C @@ -0,0 +1,17 @@ +// PR c++/38392 +// { dg-do link } + +void Function(); + +int main() +{ + Function(); +} + +template <typename T> +struct Test +{ + friend void Function() { } +}; + +template class Test<int>; |