+2010-03-31 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/43558
+ * cp-tree.h (TEMPLATE_TYPE_PARM_SIBLING_PARMS): New accessor macro.
+ * pt.c (end_template_parm_list): Store sibling template parms of
+ each TEMPLATE_TYPE_PARMs into its TEMPLATE_TYPE_PARM_SIBLING_PARMS.
+ (push_template_decl_real): Don't store the containing template decl
+ into the DECL_CONTEXT of TEMPLATE_TYPE_PARMs anymore.
+ * typeck.c (get_template_parms_of_dependent_type): Get sibling parms
+ of a TEMPLATE_TYPE_PARM from TEMPLATE_TYPE_PARM_SIBLING_PARMS.
+ Simplify the logic.
+
2010-03-30 Jason Merrill <jason@redhat.com>
PR c++/43076
(TEMPLATE_PARM_DECL (TEMPLATE_TYPE_PARM_INDEX (NODE)))
#define TEMPLATE_TYPE_PARAMETER_PACK(NODE) \
(TEMPLATE_PARM_PARAMETER_PACK (TEMPLATE_TYPE_PARM_INDEX (NODE)))
+/* The list of template parms that a given template parameter of type
+ TEMPLATE_TYPE_PARM belongs to.*/
+#define TEMPLATE_TYPE_PARM_SIBLING_PARMS(NODE) \
+ (TREE_CHECK ((NODE), TEMPLATE_TYPE_PARM))->type.maxval
/* These constants can used as bit flags in the process of tree formatting.
next = TREE_CHAIN (parm);
TREE_VEC_ELT (saved_parmlist, nparms) = parm;
TREE_CHAIN (parm) = NULL_TREE;
+ if (TREE_CODE (TREE_VALUE (parm)) == TYPE_DECL)
+ TEMPLATE_TYPE_PARM_SIBLING_PARMS (TREE_TYPE (TREE_VALUE (parm))) =
+ current_template_parms;
}
--processing_template_parmlist;
tree parm = TREE_VALUE (TREE_VEC_ELT (parms, i));
if (TREE_CODE (parm) == TEMPLATE_DECL)
DECL_CONTEXT (parm) = tmpl;
-
- if (TREE_CODE (TREE_TYPE (parm)) == TEMPLATE_TYPE_PARM)
- DECL_CONTEXT (TYPE_NAME (TREE_TYPE (parm))) = tmpl;
}
}
template info from T itself. */
if ((tinfo = get_template_info (t)))
;
- /* If T1 is a typedef or whatever has a template info associated
- to its context, get the template parameters from that context. */
+ else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM)
+ return TEMPLATE_TYPE_PARM_SIBLING_PARMS (t);
else if (typedef_variant_p (t)
&& !NAMESPACE_SCOPE_P (TYPE_NAME (t)))
tinfo = get_template_info (DECL_CONTEXT (TYPE_NAME (t)));
- else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM
- && DECL_CONTEXT (TYPE_NAME (t)) == NULL_TREE)
- /* We have not yet created the DECL_TEMPLATE this
- template type parm belongs to. It probably means
- that we are in the middle of parsing the template parameters
- of a template, and T is one of the parameters we have parsed.
- Let's return the list of template parms we have parsed so far. */
- return get_template_parms_at_level (current_template_parms,
- TEMPLATE_TYPE_LEVEL (t));
+ /* If T is a TYPENAME_TYPE which context is a template type
+ parameter, get the template parameters from that context. */
+ else if (TYPE_CONTEXT (t)
+ && TREE_CODE (TYPE_CONTEXT (t)) == TEMPLATE_TYPE_PARM)
+ return TEMPLATE_TYPE_PARM_SIBLING_PARMS (TYPE_CONTEXT (t));
else if (TYPE_CONTEXT (t)
&& !NAMESPACE_SCOPE_P (t))
tinfo = get_template_info (TYPE_CONTEXT (t));
if (tinfo)
tparms = DECL_TEMPLATE_PARMS (TI_TEMPLATE (tinfo));
- /* If T is a template type parameter, get the template parameter
- set it is part of. */
- else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM
- && DECL_CONTEXT (TYPE_NAME (t)))
- tparms = DECL_TEMPLATE_PARMS (DECL_CONTEXT (TYPE_NAME (t)));
- /* If T is a TYPENAME_TYPE which context is a template type
- parameter, get the template parameters from that context. */
- else if (TYPE_CONTEXT (t)
- && TREE_CODE (TYPE_CONTEXT (t)) == TEMPLATE_TYPE_PARM)
- tparms = get_template_parms_of_dependent_type (TYPE_CONTEXT (t));
return tparms;
}