From e17b3578a3b043e0ee9a8493224287e79f9bb2c9 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Mon, 31 May 2004 22:48:30 +0000 Subject: [PATCH] re PR c++/15701 (ICE with friends and template template parameter) PR c++/15701 * friend.c (add_friend): Do not try to perform access checks for functions from dependent classes. PR c++/15701 * g++.dg/template/friend29.C: New test. From-SVN: r82516 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/friend.c | 6 +++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/friend29.C | 11 +++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/friend29.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4ead672ef93..4549203275b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-05-31 Mark Mitchell + + PR c++/15701 + * friend.c (add_friend): Do not try to perform access checks for + functions from dependent classes. + 2004-05-31 Gabriel Dos Reis * cxx-pretty-print.c (pp_cxx_colon_colon): Expor. diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index e55adaa8bc0..f815b99f0b9 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -164,7 +164,11 @@ add_friend (tree type, tree decl, bool complain) } if (DECL_CLASS_SCOPE_P (decl)) - perform_or_defer_access_check (TYPE_BINFO (DECL_CONTEXT (decl)), decl); + { + tree class_binfo = TYPE_BINFO (DECL_CONTEXT (decl)); + if (!uses_template_parms (BINFO_TYPE (class_binfo))) + perform_or_defer_access_check (class_binfo, decl); + } maybe_add_class_template_decl_list (type, decl, /*friend_p=*/1); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a337797b1c8..67b637b3ac1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-05-31 Mark Mitchell + + PR c++/15701 + * g++.dg/template/friend29.C: New test. + 2004-05-31 Joseph S. Myers PR c/15749 diff --git a/gcc/testsuite/g++.dg/template/friend29.C b/gcc/testsuite/g++.dg/template/friend29.C new file mode 100644 index 00000000000..1c0c6f0f765 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend29.C @@ -0,0 +1,11 @@ +// PR c++/15701 + +template class T> struct A : T<0> +{ + void foo(); + template class U> friend void A::foo(); +}; + +template struct B {}; + +A a; -- 2.30.2