re PR c++/38392 (Template friend function injection)

PR c++/38392
	* pt.c (tsubst_friend_function): Instatiate a friend that has already
	been used.

From-SVN: r158073
This commit is contained in:
Jason Merrill 2010-04-07 11:54:42 -04:00 committed by Jason Merrill
parent 7dcfe861f1
commit feb3b88ad7
4 changed files with 36 additions and 5 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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.

View File

@ -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>;