aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-05-14 06:39:29 -0700
committerNathan Sidwell <nathan@acm.org>2020-05-14 06:39:29 -0700
commitc4bff4c230c8d3414bc77f7a58ffc5f61b6bd08c (patch)
tree4020d2ec18a19c8c1e247b8f1f43fe6031de115b
parent941c94747007e50ccaae6e94cf0402ff5bb63d43 (diff)
downloadgcc-c4bff4c230c8d3414bc77f7a58ffc5f61b6bd08c.zip
gcc-c4bff4c230c8d3414bc77f7a58ffc5f61b6bd08c.tar.gz
gcc-c4bff4c230c8d3414bc77f7a58ffc5f61b6bd08c.tar.bz2
c++: Improve build_template_decl
I discovered all the users of build_template_decl were explicitly setting the RESULT and TYPE fields of the built decl. Let's just have build_template_decl do that in the first place. * pt.c (build_template_decl): Init DECL_TEMPLATE_RESULT & TREE_TYPE here ... (process_partial_specialization): ... not here ... (push_template_decl_real, add_inherited_template_parms) (build_deduction_guide): ... or here.
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/pt.c13
2 files changed, 11 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5f5b31b..45b60de 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-14 Nathan Sidwell <nathan@acm.org>
+
+ * pt.c (build_template_decl): Init DECL_TEMPLATE_RESULT &
+ TREE_TYPE here ...
+ (process_partial_specialization): ... not here ...
+ (push_template_decl_real, add_inherited_template_parms)
+ (build_deduction_guide): ... or here.
+
2020-05-14 Jakub Jelinek <jakub@redhat.com>
* cp-gimplify.c (cp_genericize_r): Set cfun->has_omp_target.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index a36f603..837644f 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4883,7 +4883,9 @@ build_template_decl (tree decl, tree parms, bool member_template_p)
tree tmpl = build_lang_decl (TEMPLATE_DECL, DECL_NAME (decl), NULL_TREE);
SET_DECL_LANGUAGE (tmpl, DECL_LANGUAGE (decl));
DECL_TEMPLATE_PARMS (tmpl) = parms;
+ DECL_TEMPLATE_RESULT (tmpl) = decl;
DECL_CONTEXT (tmpl) = DECL_CONTEXT (decl);
+ TREE_TYPE (tmpl) = TREE_TYPE (decl);
DECL_SOURCE_LOCATION (tmpl) = DECL_SOURCE_LOCATION (decl);
DECL_MEMBER_TEMPLATE_P (tmpl) = member_template_p;
@@ -5233,8 +5235,6 @@ process_partial_specialization (tree decl)
// Build the template decl.
tree tmpl = build_template_decl (decl, current_template_parms,
DECL_MEMBER_TEMPLATE_P (maintmpl));
- TREE_TYPE (tmpl) = type;
- DECL_TEMPLATE_RESULT (tmpl) = decl;
SET_DECL_TEMPLATE_SPECIALIZATION (tmpl);
DECL_TEMPLATE_INFO (tmpl) = build_template_info (maintmpl, specargs);
DECL_PRIMARY_TEMPLATE (tmpl) = maintmpl;
@@ -5908,8 +5908,6 @@ push_template_decl_real (tree decl, bool is_friend)
new_tmpl
= build_template_decl (decl, current_template_parms,
member_template_p);
- DECL_TEMPLATE_RESULT (new_tmpl) = decl;
- TREE_TYPE (new_tmpl) = TREE_TYPE (decl);
DECL_TI_TEMPLATE (decl) = new_tmpl;
SET_DECL_TEMPLATE_SPECIALIZATION (new_tmpl);
DECL_TEMPLATE_INFO (new_tmpl)
@@ -5979,8 +5977,7 @@ push_template_decl_real (tree decl, bool is_friend)
}
}
- DECL_TEMPLATE_RESULT (tmpl) = decl;
- TREE_TYPE (tmpl) = TREE_TYPE (decl);
+ gcc_checking_assert (DECL_TEMPLATE_RESULT (tmpl) == decl);
/* Push template declarations for global functions and types. Note
that we do not try to push a global template friend declared in a
@@ -6085,8 +6082,6 @@ add_inherited_template_parms (tree fn, tree inherited)
tree tmpl = build_template_decl (fn, parms, /*member*/true);
tree args = template_parms_to_args (parms);
DECL_TEMPLATE_INFO (fn) = build_template_info (tmpl, args);
- TREE_TYPE (tmpl) = TREE_TYPE (fn);
- DECL_TEMPLATE_RESULT (tmpl) = fn;
DECL_ARTIFICIAL (tmpl) = true;
DECL_PRIMARY_TEMPLATE (tmpl) = tmpl;
return tmpl;
@@ -28314,8 +28309,6 @@ build_deduction_guide (tree type, tree ctor, tree outer_args, tsubst_flags_t com
DECL_NONCONVERTING_P (ded_fn) = explicit_p;
tree ded_tmpl = build_template_decl (ded_fn, tparms, /*member*/false);
DECL_ARTIFICIAL (ded_tmpl) = true;
- DECL_TEMPLATE_RESULT (ded_tmpl) = ded_fn;
- TREE_TYPE (ded_tmpl) = TREE_TYPE (ded_fn);
DECL_TEMPLATE_INFO (ded_fn) = build_template_info (ded_tmpl, targs);
DECL_PRIMARY_TEMPLATE (ded_tmpl) = ded_tmpl;
if (DECL_P (ctor))