OSDN Git Service

PR c++/38392
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Apr 2010 15:54:42 +0000 (15:54 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 00:49:50 +0000 (09:49 +0900)
* 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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog

index d3b0788..6e048ca 100644 (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.
index d1c33d6..1c0e13e 100644 (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;
index 3138c8a..3df0787 100644 (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.