diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 72bc2f07435..29901cb26fb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2001-02-06 Nathan Sidwell + + * 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 * method.c (build_mangled_name) [old abi]: Protect flush_repeats() diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a17343d7a96..e85ec792d05 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3ce1ec37058..b7b998d9e98 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-02-06 Nathan Sidwell + + * g++.old-deja/g++.pt/spec39.C: New test. + 2001-02-05 Jakub Jelinek * gcc.c-torture/compile/20010202-1.c: New test. diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec39.C b/gcc/testsuite/g++.old-deja/g++.pt/spec39.C new file mode 100644 index 00000000000..9cdf75c3d77 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec39.C @@ -0,0 +1,43 @@ +// Build don't link: +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 19 Jan 2001 + +// Bug 1656. We failed to make sure that a template-id was built +// from a primary template. + +template struct Outer +{ + struct Inner {}; + + void f() + { + Inner 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 class TPL> +struct X +{ + TPL t; + T s; // ERROR - non-template +}; + +template struct Y +{ +}; + +void bar () +{ + X a; + X b; // ERROR - non-template +}