From 866eb556c2328fa391890173a91c3108db66317b Mon Sep 17 00:00:00 2001 From: Kriang Lerdsuwanakij Date: Wed, 16 Jul 2003 15:42:15 +0000 Subject: [PATCH] re PR c++/5421 (friends+templates: ICE: expected identifier_node, have template_id_expr in grokfndecl, at cp/decl.c:8835) 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 | 8 ++++++++ gcc/cp/decl.c | 5 ++++- gcc/cp/friend.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/friend21.C | 16 ++++++++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/friend21.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4c75088..68bcb3a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2003-07-16 Kriang Lerdsuwanakij + + 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 PR c++/10903 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 9147caf..1dd2ddf 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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); diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 220b012..e31a055 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ab2deeb..68f98a1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-07-16 Kriang Lerdsuwanakij + + PR c++/5421 + * g++.dg/template/friend21.C: New test. + 2003-07-16 Jakub Jelinek * 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 index 0000000..854ed67 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend21.C @@ -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 void b(); +}; + +template class A { + friend void B::b(); +}; + +static A a; -- 2.7.4