From: Patrick Palka <ppalka@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH 1/4] c++: Avoid building garbage trees from tsubst_requires_expr
Date: Mon, 8 Feb 2021 14:03:49 -0500 [thread overview]
Message-ID: <20210208190352.1475602-1-ppalka@redhat.com> (raw)
Since we no longer partially instantiate REQUIRES_EXPRs, we don't need
to rebuild its requirements during tsubst_requires_expr.
gcc/cp/ChangeLog:
* constraint.cc (tsubst_simple_requirement): Just return
boolean_true_node on success.
(tsubst_type_requirement): Likewise.
(tsubst_compound_requirement): Likewise.
(tsubst_nested_requirement): Likewise.
(tsubst_requirement_body): Remove.
(check_constaint_variables): Rename to ...
(check_constraint_variables): ... this.
(tsubst_constraint_variables): Adjust.
(tsubst_requires_expr): Fold tsubst_requirement_body into here.
---
gcc/cp/constraint.cc | 46 ++++++++++++++------------------------------
1 file changed, 14 insertions(+), 32 deletions(-)
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 31e0fb5079a..3e599fe8c47 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -1962,7 +1962,7 @@ tsubst_simple_requirement (tree t, tree args, subst_info info)
tree expr = tsubst_valid_expression_requirement (t0, args, info);
if (expr == error_mark_node)
return error_mark_node;
- return finish_simple_requirement (EXPR_LOCATION (t), expr);
+ return boolean_true_node;
}
/* Substitute through the type requirement. */
@@ -1974,7 +1974,7 @@ tsubst_type_requirement (tree t, tree args, subst_info info)
tree type = tsubst (t0, args, info.complain, info.in_decl);
if (type == error_mark_node)
return error_mark_node;
- return finish_type_requirement (EXPR_LOCATION (t), type);
+ return boolean_true_node;
}
/* True if TYPE can be deduced from EXPR. */
@@ -2080,8 +2080,7 @@ tsubst_compound_requirement (tree t, tree args, subst_info info)
return error_mark_node;
}
- return finish_compound_requirement (EXPR_LOCATION (t),
- expr, type, noexcept_p);
+ return boolean_true_node;
}
static tree
@@ -2100,7 +2099,7 @@ tsubst_nested_requirement (tree t, tree args, subst_info info)
}
if (result != boolean_true_node)
return error_mark_node;
- return result;
+ return boolean_true_node;
}
/* Substitute ARGS into the requirement T. */
@@ -2125,24 +2124,6 @@ tsubst_requirement (tree t, tree args, subst_info info)
gcc_unreachable ();
}
-/* Substitute ARGS into the list of requirements T. Note that
- substitution failures here result in ill-formed programs. */
-
-static tree
-tsubst_requirement_body (tree t, tree args, subst_info info)
-{
- tree result = NULL_TREE;
- while (t)
- {
- tree req = tsubst_requirement (TREE_VALUE (t), args, info);
- if (req == error_mark_node)
- return error_mark_node;
- result = tree_cons (NULL_TREE, req, result);
- t = TREE_CHAIN (t);
- }
- return nreverse (result);
-}
-
static tree
declare_constraint_vars (tree parms, tree vars)
{
@@ -2168,7 +2149,7 @@ declare_constraint_vars (tree parms, tree vars)
if an error occurred. */
static tree
-check_constaint_variables (tree t, tree args, subst_info info)
+check_constraint_variables (tree t, tree args, subst_info info)
{
tree types = NULL_TREE;
tree p = t;
@@ -2193,7 +2174,7 @@ static tree
tsubst_constraint_variables (tree t, tree args, subst_info info)
{
/* Perform a trial substitution to check for type errors. */
- tree parms = check_constaint_variables (t, args, info);
+ tree parms = check_constraint_variables (t, args, info);
if (parms == error_mark_node)
return error_mark_node;
@@ -2253,19 +2234,20 @@ tsubst_requires_expr (tree t, tree args,
return t;
}
- tree parms = REQUIRES_EXPR_PARMS (t);
- if (parms)
+ if (tree parms = REQUIRES_EXPR_PARMS (t))
{
parms = tsubst_constraint_variables (parms, args, info);
if (parms == error_mark_node)
return boolean_false_node;
}
- tree reqs = REQUIRES_EXPR_REQS (t);
- reqs = tsubst_requirement_body (reqs, args, info);
- if (reqs == error_mark_node)
- return boolean_false_node;
-
+ for (tree reqs = REQUIRES_EXPR_REQS (t); reqs; reqs = TREE_CHAIN (reqs))
+ {
+ tree req = TREE_VALUE (reqs);
+ tree result = tsubst_requirement (req, args, info);
+ if (result == error_mark_node)
+ return boolean_false_node;
+ }
return boolean_true_node;
}
--
2.30.0.452.gfb7fa4a1fd
next reply other threads:[~2021-02-08 19:03 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-08 19:03 Patrick Palka [this message]
2021-02-08 19:03 ` [PATCH 2/4] c++: Preparatory type canonicalization fixes Patrick Palka
2021-02-09 5:11 ` Jason Merrill
2021-02-08 19:03 ` [PATCH 3/4] c++: Delay normalizing nested requirements until satisfaction Patrick Palka
2021-02-09 23:04 ` Jason Merrill
2021-02-10 0:52 ` Jason Merrill
2021-02-10 14:41 ` Patrick Palka
2021-02-12 19:11 ` Jason Merrill
2021-02-28 17:40 ` Patrick Palka
2021-03-01 22:23 ` Jason Merrill
2021-03-01 23:09 ` Patrick Palka
2021-03-02 2:26 ` Jason Merrill
2021-02-08 19:03 ` [PATCH 4/4] c++: dependent constraint on placeholder 'auto' [PR96443] Patrick Palka
2021-02-08 19:39 ` Patrick Palka
2021-02-11 16:19 ` Jason Merrill
2021-02-11 22:14 ` Patrick Palka
2021-02-12 19:14 ` Jason Merrill
2021-02-28 17:55 ` Patrick Palka
2021-03-01 22:31 ` Jason Merrill
2021-02-09 5:09 ` [PATCH 1/4] c++: Avoid building garbage trees from tsubst_requires_expr Jason Merrill
2021-02-28 17:58 ` [PATCH 5/6] c++: Clean up normalization / satisfaction routines Patrick Palka
2021-03-01 22:50 ` Jason Merrill
2021-03-02 16:25 ` Patrick Palka
2021-03-02 22:58 ` Jason Merrill
2021-02-28 17:59 ` [PATCH 6/6] c++: Consolidate REQUIRES_EXPR evaluation/diagnostic routines Patrick Palka
2021-03-02 2:18 ` Jason Merrill
2021-03-02 16:45 ` Patrick Palka
2021-03-02 23:04 ` Jason Merrill
2021-03-03 17:10 ` Patrick Palka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210208190352.1475602-1-ppalka@redhat.com \
--to=ppalka@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).