mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-19 00:01:21 +08:00
c++: templatey type creation
This patch makes a couple of type-creation routines available to modules. That needs to create unbound template parms, and canonical template parms. gcc/cp/ * cp-tree.h (make_unbound_class_template_raw): Declare. (canonical_type_parameter): Declare. * decl.c (make_unbound_class_template_raw): Break out of ... (make_unboud_class_template): ... here. Call it. * pt.c (canonical_type_parameter): Externalize. Refactor & set structural_equality for type parms.
This commit is contained in:
parent
756f55e62f
commit
eb8c2b30b9
@ -6542,6 +6542,7 @@ extern bool check_omp_return (void);
|
||||
extern tree make_typename_type (tree, tree, enum tag_types, tsubst_flags_t);
|
||||
extern tree build_typename_type (tree, tree, tree, tag_types);
|
||||
extern tree make_unbound_class_template (tree, tree, tree, tsubst_flags_t);
|
||||
extern tree make_unbound_class_template_raw (tree, tree, tree);
|
||||
extern tree build_library_fn_ptr (const char *, tree, int);
|
||||
extern tree build_cp_library_fn_ptr (const char *, tree, int);
|
||||
extern tree push_library_fn (tree, tree, tree, int);
|
||||
@ -6880,6 +6881,7 @@ extern void maybe_show_extern_c_location (void);
|
||||
extern bool literal_integer_zerop (const_tree);
|
||||
|
||||
/* in pt.c */
|
||||
extern tree canonical_type_parameter (tree);
|
||||
extern void push_access_scope (tree);
|
||||
extern void pop_access_scope (tree);
|
||||
extern bool check_template_shadow (tree);
|
||||
|
@ -4132,6 +4132,14 @@ make_unbound_class_template (tree context, tree name, tree parm_list,
|
||||
return tmpl;
|
||||
}
|
||||
|
||||
return make_unbound_class_template_raw (context, name, parm_list);
|
||||
}
|
||||
|
||||
/* Build an UNBOUND_CLASS_TEMPLATE. */
|
||||
|
||||
tree
|
||||
make_unbound_class_template_raw (tree context, tree name, tree parm_list)
|
||||
{
|
||||
/* Build the UNBOUND_CLASS_TEMPLATE. */
|
||||
tree t = cxx_make_type (UNBOUND_CLASS_TEMPLATE);
|
||||
TYPE_CONTEXT (t) = FROB_CONTEXT (context);
|
||||
|
27
gcc/cp/pt.c
27
gcc/cp/pt.c
@ -4432,7 +4432,7 @@ build_template_parm_index (int index,
|
||||
parameter. Returns the canonical type parameter, which may be TYPE
|
||||
if no such parameter existed. */
|
||||
|
||||
static tree
|
||||
tree
|
||||
canonical_type_parameter (tree type)
|
||||
{
|
||||
int idx = TEMPLATE_TYPE_IDX (type);
|
||||
@ -13212,19 +13212,24 @@ tsubst_argument_pack (tree orig_arg, tree args, tsubst_flags_t complain,
|
||||
tree in_decl)
|
||||
{
|
||||
/* Substitute into each of the arguments. */
|
||||
tree new_arg = TYPE_P (orig_arg)
|
||||
? cxx_make_type (TREE_CODE (orig_arg))
|
||||
: make_node (TREE_CODE (orig_arg));
|
||||
|
||||
tree pack_args = tsubst_template_args (ARGUMENT_PACK_ARGS (orig_arg),
|
||||
args, complain, in_decl);
|
||||
if (pack_args == error_mark_node)
|
||||
new_arg = error_mark_node;
|
||||
else
|
||||
SET_ARGUMENT_PACK_ARGS (new_arg, pack_args);
|
||||
tree new_arg = error_mark_node;
|
||||
if (pack_args != error_mark_node)
|
||||
{
|
||||
if (TYPE_P (orig_arg))
|
||||
{
|
||||
new_arg = cxx_make_type (TREE_CODE (orig_arg));
|
||||
SET_TYPE_STRUCTURAL_EQUALITY (new_arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_arg = make_node (TREE_CODE (orig_arg));
|
||||
TREE_CONSTANT (new_arg) = TREE_CONSTANT (orig_arg);
|
||||
}
|
||||
|
||||
if (TREE_CODE (new_arg) == NONTYPE_ARGUMENT_PACK)
|
||||
TREE_CONSTANT (new_arg) = TREE_CONSTANT (orig_arg);
|
||||
SET_ARGUMENT_PACK_ARGS (new_arg, pack_args);
|
||||
}
|
||||
|
||||
return new_arg;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user