diff options
author | Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> | 2003-07-16 15:42:15 +0000 |
---|---|---|
committer | Kriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org> | 2003-07-16 15:42:15 +0000 |
commit | 866eb556c2328fa391890173a91c3108db66317b (patch) | |
tree | ce989dcd709f54247a75f3bf17e5c9c1ca60836c /gcc | |
parent | 94b7906a3a8ea86c701bef97d31f6fdf22db7fc7 (diff) | |
download | gcc-866eb556c2328fa391890173a91c3108db66317b.zip gcc-866eb556c2328fa391890173a91c3108db66317b.tar.gz gcc-866eb556c2328fa391890173a91c3108db66317b.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/decl.c | 5 | ||||
-rw-r--r-- | gcc/cp/friend.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/friend21.C | 16 |
5 files changed, 35 insertions, 1 deletions
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 <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 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 <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 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 <class T> void b(); +}; + +template <class T> class A { + friend void B::b<T>(); +}; + +static A<int> a; |