This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: Fix bug 1656
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH]: Fix bug 1656
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Tue, 06 Feb 2001 10:55:12 +0000
- Organization: Codesourcery LLC
Hi,
I've installed this patch for bug 1656. We were accepting ill formed source
because nested classes of template classes are treated as templates, but
should not be user-visible ones.
built and tested on i686-pc-linux-gnu, approved by Mark. [Mark,
the explicit 'from-parser' flag did not work out.]
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
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.
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/pt.c,v
retrieving revision 1.513
diff -c -3 -p -r1.513 pt.c
*** pt.c 2001/01/29 18:57:22 1.513
--- pt.c 2001/02/06 10:28:29
*************** lookup_template_class (d1, arglist, in_d
*** 3893,3899 ****
return error_mark_node;
}
! if (TREE_CODE (template) != TEMPLATE_DECL)
{
if (complain)
{
--- 3893,3904 ----
return error_mark_node;
}
! 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)
{
*************** instantiate_class_template (type)
*** 5109,5114 ****
--- 5114,5120 ----
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))
// 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
}