From 5ce49b4b08490bb2dc9a8f669fcc145a344cd73d Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Thu, 27 Jun 2002 21:45:56 +0000 Subject: [PATCH] re PR c++/6695 (Regression: template friend declaration doesn't work) PR c++/6695 * pt.c (tsubst_friend_class): Substitute into the context of the friend before using it. PR c++/6695 * g++.dg/template/friend7.C: New file. From-SVN: r55041 --- gcc/cp/ChangeLog | 6 +++++ gcc/cp/pt.c | 2 +- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/template/friend7.C | 33 +++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/friend7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5f2a0b35c75..d9f06b5a1cc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2002-06-27 Mark Mitchell + + PR c++/6695 + * pt.c (tsubst_friend_class): Substitute into the context of the + friend before using it. + 2002-06-26 Mark Mitchell * cp-tree.h (xref_tag): Change prototype. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index cdc1aa0358d..46de8dac6f4 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4836,7 +4836,7 @@ tsubst_friend_class (friend_tmpl, args) if (TREE_CODE (context) == NAMESPACE_DECL) push_nested_namespace (context); else - push_nested_class (context, 2); + push_nested_class (tsubst (context, args, tf_none, NULL_TREE), 2); } /* First, we look for a class template. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 55d809bb2d3..ed515741298 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2002-06-27 Mark Mitchell + + PR c++/6695 + * g++.dg/template/friend7.C: New file. + 2002-06-27 Aldy Hernandez * gcc.c-torture/execute/string-opt-8.c (strncmp): Fix typo in diff --git a/gcc/testsuite/g++.dg/template/friend7.C b/gcc/testsuite/g++.dg/template/friend7.C new file mode 100644 index 00000000000..a954f8990c5 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend7.C @@ -0,0 +1,33 @@ +// { dg-do compile } + +template +struct b +{ + template + class a + { + template + friend class a; + + T t_; + + public: + a() {} + a(a const &); + }; +}; + +template +template +b::a::a(a const &rhs): t_(*rhs.t_) +{} + + +int +f () +{ + b::a q; + b::a w(q); + + return 0; +}