This patch concludes with simplifying TYPE_TEMPLATE_INFO. It was too
tricky, given the time available, to make TYPE_TEMPLATE_INFO require a
templatable _TYPE node, so it remains returning NULL_TREE if you give it
a random _TYPE node. That'd be nice to clean up though.
I can't recall the underlying reason why TEMPLATE_TEMPLATE_PARM was
forked to add BOUND_TEMPLATE_TEMPLATE_PARM. Naively it seems these are
distinguished by the absence or presence of TEMPLATE_INFO. But again,
too fiddly to examine right now.
nathan
--
Nathan Sidwell
2017-08-17 Nathan Sidwell <nat...@acm.org>
* cp-tree.def (TEMPLATE_TEMPLATE_PARM): Remove stale comment.
* cp-tree.h (ENUM_TEMPLATE_INFO): Delete.
(TYPE_TEMPLATE_INFO): Simplify.
(SET_TYPE_TEMPLATE_INFO): Simplify.
Index: cp-tree.def
===================================================================
--- cp-tree.def (revision 251152)
+++ cp-tree.def (working copy)
@@ -163,8 +163,7 @@ DEFTREECODE (TEMPLATE_PARM_INDEX, "templ
TEMPLATE_PARM_INDEX.
It is used without template arguments like TT in C<TT>,
- TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO is NULL_TREE
- and TYPE_NAME is a TEMPLATE_DECL. */
+ TYPE_NAME is a TEMPLATE_DECL. */
DEFTREECODE (TEMPLATE_TEMPLATE_PARM, "template_template_parm", tcc_type, 0)
/* The ordering of the following codes is optimized for the checking
Index: cp-tree.h
===================================================================
--- cp-tree.h (revision 251152)
+++ cp-tree.h (working copy)
@@ -473,10 +473,8 @@ extern GTY(()) tree cp_global_trees[CPTI
TYPE_LANG_SLOT_1
For a FUNCTION_TYPE or METHOD_TYPE, this is TYPE_RAISES_EXCEPTIONS.
For a POINTER_TYPE (to a METHOD_TYPE), this is TYPE_PTRMEMFUNC_TYPE.
- For an ENUMERAL_TYPE, this is ENUM_TEMPLATE_INFO.
- For a RECORD_TYPE or UNION_TYPE this is CLASSTYPE_TEMPLATE_INFO,
- For a BOUND_TEMPLATE_TEMPLATE_PARM_TYPE this is also
- TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO.
+ For an ENUMERAL_TYPE, BOUND_TEMPLATE_TEMPLATE_PARM_TYPE,
+ RECORD_TYPE or UNION_TYPE this is TYPE_TEMPLATE_INFO,
BINFO_VIRTUALS
For a binfo, this is a TREE_LIST. There is an entry for each
@@ -3280,28 +3278,20 @@ extern void decl_shadowed_for_var_insert
#define CLASSTYPE_TEMPLATE_INFO(NODE) \
(TYPE_LANG_SLOT_1 (RECORD_OR_UNION_CHECK (NODE)))
-/* Template information for an ENUMERAL_TYPE. Although an enumeration may
- not be a primary template, it may be declared within the scope of a
- primary template and the enumeration constants may depend on
- non-type template parameters. */
-#define ENUM_TEMPLATE_INFO(NODE) \
- (TYPE_LANG_SLOT_1 (ENUMERAL_TYPE_CHECK (NODE)))
-
/* Template information for a template template parameter. */
#define TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO(NODE) \
(TYPE_LANG_SLOT_1 (BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK (NODE)))
/* Template information for an ENUMERAL_, RECORD_, UNION_TYPE, or
BOUND_TEMPLATE_TEMPLATE_PARM type. This ignores any alias
- templateness of NODE. */
+ templateness of NODE. It'd be nice if this could unconditionally
+ access the slot, rather than return NULL if given a
+ non-templatable type. */
#define TYPE_TEMPLATE_INFO(NODE) \
(TREE_CODE (NODE) == ENUMERAL_TYPE \
- ? ENUM_TEMPLATE_INFO (NODE) \
- : (TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM \
- ? TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (NODE) \
- : (CLASS_TYPE_P (NODE) \
- ? CLASSTYPE_TEMPLATE_INFO (NODE) \
- : NULL_TREE)))
+ || TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM \
+ || RECORD_OR_UNION_TYPE_P (NODE) \
+ ? TYPE_LANG_SLOT_1 (NODE) : NULL_TREE)
/* Template information (if any) for an alias type. */
#define TYPE_ALIAS_TEMPLATE_INFO(NODE) \
@@ -3321,10 +3311,9 @@ extern void decl_shadowed_for_var_insert
UNION_TYPE to VAL. */
#define SET_TYPE_TEMPLATE_INFO(NODE, VAL) \
(TREE_CODE (NODE) == ENUMERAL_TYPE \
- ? (ENUM_TEMPLATE_INFO (NODE) = (VAL)) \
- : ((CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE)) \
- ? (CLASSTYPE_TEMPLATE_INFO (NODE) = (VAL)) \
- : (DECL_TEMPLATE_INFO (TYPE_NAME (NODE)) = (VAL))))
+ || (CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE)) \
+ ? (TYPE_LANG_SLOT_1 (NODE) = (VAL)) \
+ : (DECL_TEMPLATE_INFO (TYPE_NAME (NODE)) = (VAL)))
#define TI_TEMPLATE(NODE) TREE_TYPE (TEMPLATE_INFO_CHECK (NODE))
#define TI_ARGS(NODE) TREE_CHAIN (TEMPLATE_INFO_CHECK (NODE))