diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2001-02-06 10:49:44 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2001-02-06 10:49:44 +0000 |
commit | a87b4257946d4453f250585aa22adc4f70db1165 (patch) | |
tree | 6a08cb3fd371edfc5ba41f41aca58244a2e031de /gcc | |
parent | 4050de4912df9909d867d887c60378c7a74621f9 (diff) | |
download | gcc-a87b4257946d4453f250585aa22adc4f70db1165.zip gcc-a87b4257946d4453f250585aa22adc4f70db1165.tar.gz gcc-a87b4257946d4453f250585aa22adc4f70db1165.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.pt/spec39.C | 43 |
4 files changed, 60 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 72bc2f0..29901cb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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() diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a17343d..e85ec792 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 3ce1ec3..b7b998d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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. 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 0000000..9cdf75c --- /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 <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 +} |