From 679ea2c154192a3f8c7c248feea9c4fbaaab5dd0 Mon Sep 17 00:00:00 2001 From: mmitchel Date: Wed, 6 Jun 2001 07:00:28 +0000 Subject: [PATCH] * semantics.c (begin_class_definition): Robustify. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-3_0-branch@42936 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 2 ++ gcc/cp/semantics.c | 25 ++++++++++++++++++------- gcc/testsuite/g++.old-deja/g++.pt/memtemp99.C | 10 ++++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/memtemp99.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a74be339951..efa847b071b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,7 @@ 2001-06-05 Mark Mitchell + * semantics.c (begin_class_definition): Robustify. + * pt.c (instantiate_decl): Tell the repository code about the clones, not the cloned functions. * repo.c (repo_template_used): Explicitly instantiate the cloned diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index fd28846e938..4a021ca706a 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1733,18 +1733,29 @@ begin_class_definition (t) cp_error ("definition of `%#T' inside template parameter list", t); return error_mark_node; } - if (t == error_mark_node - || ! IS_AGGR_TYPE (t)) + + /* In a definition of a member class template, we will get here with + an implicit typename. */ + if (IMPLICIT_TYPENAME_P (t)) + t = TREE_TYPE (t); + /* A non-implicit typename comes from code like: + + template struct A { + template struct A::B ... + + This is erroneous. */ + else if (TREE_CODE (t) == TYPENAME_TYPE) + { + cp_error ("invalid definition of qualified type `%T'", t); + t = error_mark_node; + } + + if (t == error_mark_node || ! IS_AGGR_TYPE (t)) { t = make_aggr_type (RECORD_TYPE); pushtag (make_anon_name (), t, 0); } - /* In a definition of a member class template, we will get here with an - implicit typename, a TYPENAME_TYPE with a type. */ - if (TREE_CODE (t) == TYPENAME_TYPE) - t = TREE_TYPE (t); - /* If we generated a partial instantiation of this type, but now we're seeing a real definition, we're actually looking at a partial specialization. Consider: diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp99.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp99.C new file mode 100644 index 00000000000..2295bea022d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp99.C @@ -0,0 +1,10 @@ +// Build don't link: +// Origin: bitti@cs.tut.fi + +template +class Vector +{ +public: + template + class Vector::CommaInit { }; // ERROR - invalid definition +}; -- 2.11.4.GIT