From 1c10870d31b0112b409fef7241126a81d8b4f63b Mon Sep 17 00:00:00 2001 From: Alex Samuel Date: Mon, 30 Aug 1999 05:22:45 +0000 Subject: [PATCH] pt.c (push_template_decl_real): Use template declaration from class type if it exists. * pt.c (push_template_decl_real): Use template declaration from class type if it exists. From-SVN: r28978 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 16 ++++++++++++++++ gcc/testsuite/g++.old-deja/g++.ns/template14.C | 14 ++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/g++.old-deja/g++.ns/template14.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0fa5c607127..4a8fd5ac0c2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1999-08-29 Alex Samuel + + * pt.c (push_template_decl_real): Use template declaration from + class type if it exists. + 1999-08-29 Mark Mitchell * cp-tree.h (TYPE_NEEDS_CONSTRUCTING): Remove #if 0'd definition. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e321c348e9b..ee6f85ac4be 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2461,6 +2461,22 @@ push_template_decl_real (decl, is_friend) && DECL_TEMPLATE_INFO (decl) && DECL_TI_TEMPLATE (decl)) tmpl = DECL_TI_TEMPLATE (decl); + /* If DECL is a TYPE_DECL for a class-template, then there won't + be DECL_LANG_SPECIFIC. The information equivalent to + DECL_TEMPLATE_INFO is found in TYPE_TEMPLATE_INFO instead. */ + else if (DECL_IMPLICIT_TYPEDEF_P (decl) + && TYPE_TEMPLATE_INFO (TREE_TYPE (decl)) + && TYPE_TI_TEMPLATE (TREE_TYPE (decl))) + { + /* Since a template declaration already existed for this + class-type, we must be redeclaring it here. Make sure + that the redeclaration is legal. */ + redeclare_class_template (TREE_TYPE (decl), + current_template_parms); + /* We don't need to create a new TEMPLATE_DECL; just use the + one we already had. */ + tmpl = TYPE_TI_TEMPLATE (TREE_TYPE (decl)); + } else { tmpl = build_template_decl (decl, current_template_parms); diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template14.C b/gcc/testsuite/g++.old-deja/g++.ns/template14.C new file mode 100644 index 00000000000..90e5312aa76 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template14.C @@ -0,0 +1,14 @@ +// Build don't link: +// Origin: Alex Samuel + +namespace Outer +{ +template class Inner; +} + +template +class Outer::Inner +{ +public: + Inner (); +}; -- 2.30.2