From 68c788471ba4f3a2aa4e79c6fc2bf99218621bc3 Mon Sep 17 00:00:00 2001 From: Kriang Lerdsuwanakij Date: Fri, 19 Sep 2003 14:08:00 +0000 Subject: re PR c++/495 (ICE in in lookup_template_class, at cp/pt.c:3961) PR c++/495 * pt.c (tsubst_friend_class): Only use innermost template arguments for the injected friend class template. * g++.dg/template/friend24.C: New test. From-SVN: r71574 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/friend24.C | 27 +++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/friend24.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 15bf1a6f..a18706b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-09-19 Kriang Lerdsuwanakij + + PR c++/495 + * pt.c (tsubst_friend_class): Only use innermost template + arguments for the injected friend class template. + 2003-09-19 Nathan Sidwell PR c++/12332 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 28ed0bc..5e5af5b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5001,6 +5001,8 @@ tsubst_friend_class (tree friend_tmpl, tree args) DECL_USE_TEMPLATE (tmpl) = 0; DECL_TEMPLATE_INFO (tmpl) = NULL_TREE; CLASSTYPE_USE_TEMPLATE (TREE_TYPE (tmpl)) = 0; + CLASSTYPE_TI_ARGS (TREE_TYPE (tmpl)) + = INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (TREE_TYPE (tmpl))); /* Inject this template into the global scope. */ friend_type = TREE_TYPE (pushdecl_top_level (tmpl)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2b1e566..77a2c4b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-09-19 Kriang Lerdsuwanakij + + PR c++/495 + * g++.dg/template/friend24.C: New test. + 2003-09-19 Nathan Sidwell PR c++/12332 diff --git a/gcc/testsuite/g++.dg/template/friend24.C b/gcc/testsuite/g++.dg/template/friend24.C new file mode 100644 index 0000000..5db4d31 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend24.C @@ -0,0 +1,27 @@ +// { dg-do compile } + +// Origin: Wolfgang Bangerth + +// PR c++/495: Fail to locate primary class template that is +// injected by friend declaration. + +template struct X +{ + template friend struct Y; +}; + +X<2> x; + +template struct Y +{ + void f (Y); + void g (Y); +}; + +template void Y::f (Y) +{ +} + +template void Y::g (Y) +{ +} -- cgit v1.1