This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for member class templates
- To: egcs-patches at cygnus dot com
- Subject: C++ PATCH for member class templates
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Wed, 14 Oct 1998 20:25:48 -0700
- Cc: Jason Merrill <jason at cygnus dot com>
- Reply-to: mark at markmitchell dot com
This patch fixes an inconsistency (that causes a crash in certain
cases) w.r.t. member templates. In particular, a class template _TYPE
node should have CLASSTYPE_USE_TEMPLATE == 0.
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com
1998-10-14 Mark Mitchell <mark@markmitchell.com>
* pt.c (lookup_template_class): Add comment.
(instantiate_class_template): Don't mark the _TYPE node for
member class templates as an instantiation.
Index: pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.213
diff -c -p -r1.213 pt.c
*** pt.c 1998/10/13 14:34:26 1.213
--- pt.c 1998/10/15 03:15:38
*************** void
*************** lookup_template_class (d1, arglist, in_d
*** 3547,3553 ****
push_obstacks (&permanent_obstack, &permanent_obstack);
/* This type is a "partial instantiation" if any of the template
! arguments still inolve template parameters. */
is_partial_instantiation = uses_template_parms (arglist);
/* Create the type. */
--- 3549,3557 ----
push_obstacks (&permanent_obstack, &permanent_obstack);
/* This type is a "partial instantiation" if any of the template
! arguments still inolve template parameters. Note that we set
! IS_PARTIAL_INSTANTIATION for partial specializations as
! well. */
is_partial_instantiation = uses_template_parms (arglist);
/* Create the type. */
*************** instantiate_class_template (type)
*** 4519,4524 ****
--- 4523,4540 ----
newtag = tsubst (tag, args, NULL_TREE);
if (TREE_CODE (newtag) != ENUMERAL_TYPE)
{
+ if (TYPE_LANG_SPECIFIC (tag)
+ && CLASSTYPE_IS_TEMPLATE (tag))
+ /* Unfortunately, lookup_template_class sets
+ CLASSTYPE_IMPLICIT_INSTANTIATION for a partial
+ instantiation (i.e., for the type of a member template
+ class nested within a template class.) This behavior is
+ required for maybe_process_partial_specialization to work
+ correctly, but is not accurate in this case; the TAG is not
+ an instantiation of anything. (The corresponding
+ TEMPLATE_DECL is an instantiation, but the TYPE is not.) */
+ CLASSTYPE_USE_TEMPLATE (newtag) = 0;
+
/* Now, we call pushtag to put this NEWTAG into the scope of
TYPE. We first set up the IDENTIFIER_TYPE_VALUE to avoid
pushtag calling push_template_decl. We don't have to do