public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-126] c++: simplify TEMPLATE_TYPE_PARM level lowering
@ 2023-04-20 19:17 Patrick Palka
0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2023-04-20 19:17 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:afc7e20e793ce4071a7fe593ccebb2e6b2b070fa
commit r14-126-gafc7e20e793ce4071a7fe593ccebb2e6b2b070fa
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Apr 20 15:16:59 2023 -0400
c++: simplify TEMPLATE_TYPE_PARM level lowering
1. Don't bother recursing when level lowering a cv-qualified type
template parameter.
2. Get rid of the recursive loop breaker when level lowering a
constrained auto, and enable the TEMPLATE_PARM_DESCENDANTS cache in
this case too. This should be safe to do so now that we no longer
substitute constraints on an auto.
gcc/cp/ChangeLog:
* pt.cc (tsubst) <case TEMPLATE_TYPE_PARM>: Don't recurse when
level lowering a cv-qualified type template parameter. Remove
recursive loop breaker in the level lowering case for constrained
autos. Use the TEMPLATE_PARM_DESCENDANTS cache in this case as
well.
Diff:
---
gcc/cp/pt.cc | 37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index d393c99ba9e..3e5f0104056 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -16228,33 +16228,24 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
/* If we get here, we must have been looking at a parm for a
more deeply nested template. Make a new version of this
template parameter, but with a lower level. */
+ int quals;
switch (code)
{
case TEMPLATE_TYPE_PARM:
case TEMPLATE_TEMPLATE_PARM:
- if (cp_type_quals (t))
+ quals = cp_type_quals (t);
+ if (quals)
{
- r = tsubst (TYPE_MAIN_VARIANT (t), args, complain, in_decl);
- r = cp_build_qualified_type
- (r, cp_type_quals (t),
- complain | (code == TEMPLATE_TYPE_PARM
- ? tf_ignore_bad_quals : 0));
+ gcc_checking_assert (code == TEMPLATE_TYPE_PARM);
+ t = TYPE_MAIN_VARIANT (t);
}
- else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM
- && PLACEHOLDER_TYPE_CONSTRAINTS_INFO (t)
- && (r = (TEMPLATE_PARM_DESCENDANTS
- (TEMPLATE_TYPE_PARM_INDEX (t))))
- && (r = TREE_TYPE (r))
- && !PLACEHOLDER_TYPE_CONSTRAINTS_INFO (r))
- /* Break infinite recursion when substituting the constraints
- of a constrained placeholder. */;
- else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM
- && !PLACEHOLDER_TYPE_CONSTRAINTS_INFO (t)
- && (arg = TEMPLATE_TYPE_PARM_INDEX (t),
- r = TEMPLATE_PARM_DESCENDANTS (arg))
- && (TEMPLATE_PARM_LEVEL (r)
- == TEMPLATE_PARM_LEVEL (arg) - levels))
- /* Cache the simple case of lowering a type parameter. */
+
+ if (TREE_CODE (t) == TEMPLATE_TYPE_PARM
+ && (arg = TEMPLATE_TYPE_PARM_INDEX (t),
+ r = TEMPLATE_PARM_DESCENDANTS (arg))
+ && (TEMPLATE_PARM_LEVEL (r)
+ == TEMPLATE_PARM_LEVEL (arg) - levels))
+ /* Cache the simple case of lowering a type parameter. */
r = TREE_TYPE (r);
else
{
@@ -16278,6 +16269,10 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
else
TYPE_CANONICAL (r) = canonical_type_parameter (r);
}
+
+ if (quals)
+ r = cp_build_qualified_type (r, quals,
+ complain | tf_ignore_bad_quals);
break;
case BOUND_TEMPLATE_TEMPLATE_PARM:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-20 19:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-20 19:17 [gcc r14-126] c++: simplify TEMPLATE_TYPE_PARM level lowering Patrick Palka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).