aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-12-03 08:58:44 -0800
committerNathan Sidwell <nathan@acm.org>2020-12-03 09:01:43 -0800
commiteb8c2b30b947dd8a2012ee658117bea05e46bc85 (patch)
treea5a9723ff925a0da5742df39794d98de9c89f098 /gcc
parent756f55e62f73eb32787497eb9e564d4b21a6e637 (diff)
downloadgcc-eb8c2b30b947dd8a2012ee658117bea05e46bc85.zip
gcc-eb8c2b30b947dd8a2012ee658117bea05e46bc85.tar.gz
gcc-eb8c2b30b947dd8a2012ee658117bea05e46bc85.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/decl.c8
-rw-r--r--gcc/cp/pt.c27
3 files changed, 26 insertions, 11 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index de905dc..69f8ed5 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 0cf84a0..a28e792 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 66ac647..3ca2813 100644
--- a/gcc/cp/pt.c
+++ b/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;
}