re PR c++/5421 (friends+templates: ICE: expected identifier_node, have template_id_ex...
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Wed, 16 Jul 2003 15:42:15 +0000 (15:42 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Wed, 16 Jul 2003 15:42:15 +0000 (15:42 +0000)
PR c++/5421
* decl.c (grokdeclarator): Handle TEMPLATE_ID_EXPR if friend
is a member of other class.
* friend.c (do_friend): Don't build TEMPLATE_DECL if friend
is a specialization of function template.

* g++.dg/template/friend21.C: New test.

From-SVN: r69457

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/friend.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/friend21.C [new file with mode: 0644]

index 4c75088..68bcb3a 100644 (file)
@@ -1,3 +1,11 @@
+2003-07-16  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/5421
+       * decl.c (grokdeclarator): Handle TEMPLATE_ID_EXPR if friend
+       is a member of other class.
+       * friend.c (do_friend): Don't build TEMPLATE_DECL if friend
+       is a specialization of function template.
+
 2003-07-16  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        PR c++/10903
index 9147caf..1dd2ddf 100644 (file)
@@ -11488,7 +11488,10 @@ grokdeclarator (tree declarator,
               members of other classes.  */
            /* All method decls are public, so tell grokfndecl to set
               TREE_PUBLIC, also.  */
-           decl = grokfndecl (ctype, type, declarator, declarator,
+           decl = grokfndecl (ctype, type,
+                              TREE_CODE (declarator) != TEMPLATE_ID_EXPR
+                              ? declarator : dname,
+                              declarator,
                               virtualp, flags, quals, raises,
                               friendp ? -1 : 0, friendp, 1, 0, funcdef_flag,
                               template_count, in_namespace);
index 220b012..e31a055 100644 (file)
@@ -357,6 +357,8 @@ do_friend (tree ctype, tree declarator, tree decl, tree parmdecls,
 
       if (is_friend_template)
        decl = DECL_TI_TEMPLATE (push_template_decl (decl));
+      else if (DECL_TEMPLATE_INFO (decl))
+       ;
       else if (template_class_depth (current_class_type))
        decl = push_template_decl_real (decl, /*is_friend=*/1);
 
index ab2deeb..68f98a1 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-16  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/5421
+       * g++.dg/template/friend21.C: New test.
+
 2003-07-16  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.dg/cleanup-8.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/friend21.C b/gcc/testsuite/g++.dg/template/friend21.C
new file mode 100644 (file)
index 0000000..854ed67
--- /dev/null
@@ -0,0 +1,16 @@
+// { dg-do compile }
+
+// Origin: ajl13@bellatlantic.net
+
+// PR c++/5421: ICE for specialization of member function template
+// as friend.
+
+struct B {
+  template <class T> void b();
+};
+
+template <class T> class A {
+  friend void B::b<T>();
+};
+
+static A<int> a;