pt.c (tsubst_friend_class): Don't call redeclare_class_template if the template we...
authorJason Merrill <jason@yorick.cygnus.com>
Thu, 21 May 1998 20:57:52 +0000 (20:57 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 21 May 1998 20:57:52 +0000 (16:57 -0400)
* pt.c (tsubst_friend_class): Don't call redeclare_class_template
if the template we looked up is the same as the one we already
have.

From-SVN: r19935

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

index e0a339913c9e72492a4a3cea6aacfda7ae83b032..fe748e48556e29ce0352e224442e56db0b7afd56 100644 (file)
@@ -1,3 +1,9 @@
+1998-05-21  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * pt.c (tsubst_friend_class): Don't call redeclare_class_template
+       if the template we looked up is the same as the one we already
+       have.
+
 Thu May 21 11:54:44 1998  Dave Brolley  <brolley@cygnus.com>
 
        * lex.c: (handle_sysv_pragma): FILE* parameter not used.
index 2e50cf981097bd0d48a1573eb1bc156310856e95..8763df3ad1fdf813983cff6697810ca3c74b1a10 100644 (file)
@@ -3510,8 +3510,8 @@ tsubst_friend_class (friend_type, args)
      tree friend_type;
      tree args;
 {
-  tree tmpl = 
-    lookup_name (DECL_NAME (CLASSTYPE_TI_TEMPLATE (friend_type)), 1); 
+  tree friend_tmpl = CLASSTYPE_TI_TEMPLATE (friend_type);
+  tree tmpl = lookup_name (DECL_NAME (friend_tmpl), 1); 
 
   tmpl = maybe_get_template_decl_from_type_decl (tmpl);
 
@@ -3519,9 +3519,9 @@ tsubst_friend_class (friend_type, args)
     {
       /* The friend template has already been declared.  Just
         check to see that the declarations match.  */
-      redeclare_class_template (TREE_TYPE (tmpl),
-                               DECL_TEMPLATE_PARMS (CLASSTYPE_TI_TEMPLATE 
-                                                    (friend_type)));
+      if (tmpl != friend_tmpl)
+       redeclare_class_template (TREE_TYPE (tmpl),
+                                 DECL_TEMPLATE_PARMS (friend_tmpl));
       friend_type = TREE_TYPE (tmpl);
     }
   else
@@ -3529,7 +3529,7 @@ tsubst_friend_class (friend_type, args)
       /* The friend template has not already been declared.  In this
         case, the instantiation of the template class will cause the
         injection of this template into the global scope.  */
-      tmpl = tsubst (CLASSTYPE_TI_TEMPLATE (friend_type), args, NULL_TREE);
+      tmpl = tsubst (friend_tmpl, args, NULL_TREE);
 
       /* The new TMPL is not an instantiation of anything, so we
         forget its origins.  We don't reset CLASSTYPE_TI_TEMPLATE for