pt.c (lookup_template_class): Make sure it's a primary template or template_template_parm when...

cp:
	* pt.c (lookup_template_class): Make sure it's a primary
	template or template_template_parm when called from the parser.
	(instantiate_template_class): Add assertion.
testsuite:
	* g++.old-deja/g++.pt/spec39.C: New test.

From-SVN: r39488
This commit is contained in:
Nathan Sidwell 2001-02-06 10:49:44 +00:00 committed by Nathan Sidwell
parent 4050de4912
commit a87b425794
4 changed files with 60 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2001-02-06 Nathan Sidwell <nathan@codesourcery.com>
* pt.c (lookup_template_class): Make sure it's a primary
template or template_template_parm when called from the parser.
(instantiate_template_class): Add assertion.
2001-02-05 Alexandre Oliva <aoliva@redhat.com>
* method.c (build_mangled_name) [old abi]: Protect flush_repeats()

View File

@ -3893,7 +3893,12 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope, complain)
return error_mark_node;
}
if (TREE_CODE (template) != TEMPLATE_DECL)
if (TREE_CODE (template) != TEMPLATE_DECL
/* If we're called from the parser, make sure it's a user visible
template. */
|| ((!arglist || TREE_CODE (arglist) == TREE_LIST)
&& !DECL_TEMPLATE_PARM_P (template)
&& !PRIMARY_TEMPLATE_P (template)))
{
if (complain)
{
@ -5109,6 +5114,7 @@ instantiate_class_template (type)
tree newtag;
newtag = tsubst (tag, args, /*complain=*/1, NULL_TREE);
my_friendly_assert (newtag != error_mark_node, 20010206);
if (TREE_CODE (newtag) != ENUMERAL_TYPE)
{
if (TYPE_LANG_SPECIFIC (tag) && CLASSTYPE_IS_TEMPLATE (tag))

View File

@ -1,3 +1,7 @@
2001-02-06 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.pt/spec39.C: New test.
2001-02-05 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/compile/20010202-1.c: New test.

View File

@ -0,0 +1,43 @@
// Build don't link:
//
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 19 Jan 2001 <nathan@codesourcery.com>
// Bug 1656. We failed to make sure that a template-id was built
// from a primary template.
template <int dim> struct Outer
{
struct Inner {};
void f()
{
Inner<dim> i; // ERROR - non-template
Inner<> j; // ERROR - non-template
}
};
struct O {};
void foo ()
{
Outer<1> x;
x.f ();
Outer<1>::Inner<2> z; // ERROR - non-template
O<1> w; // ERROR - non-template
}
template <typename T, template <typename C> class TPL>
struct X
{
TPL<T> t;
T<int> s; // ERROR - non-template
};
template <typename T> struct Y
{
};
void bar ()
{
X<int, Y> a;
X<int, O> b; // ERROR - non-template
}