mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-11 15:41:06 +08:00
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:
parent
7dcfe861f1
commit
feb3b88ad7
@ -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.
|
||||
|
17
gcc/cp/pt.c
17
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;
|
||||
|
@ -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.
|
||||
|
||||
|
17
gcc/testsuite/g++.dg/template/friend51.C
Normal file
17
gcc/testsuite/g++.dg/template/friend51.C
Normal 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>;
|
Loading…
x
Reference in New Issue
Block a user