On 10/19/20 6:08 PM, Patrick Palka wrote:
Many of the high-level constraint normalization routines allow the
caller to supply the initial template arguments for normalization, but
in practice all of the callers ultimately supply either NULL_TREE or a
set of generic template arguments (*).  Since the previous patch made
NULL_TREE act like a set of generic template arguments during
normalization, we can just make get_normalized_constraints pass
NULL_TREE to normalize_expression and remove the 'args' parameter from
the routines that wrap it.

(*): Except one of the overloads of normalize_constraint_expression uses
the template arguments of a concept check for normalizing the concept
check, which doesn't seem right, since if a substitution failure happens
during normalization then it will become a hard error instead of a
SFINAE error.  This patch does away with this overload.

Bootstrapped and regtested on x86_64-pc-linux-gnu and tested on the
cmcstl2 testsuite.  Also verified that the concepts diagnostics remain
unchanged across our testsuite.  Doest this look OK to commit?

OK.

gcc/cp/ChangeLog:

        * constraint.cc (get_normalized_constraints): Remove 'args'
        parameter.  Pass NULL_TREE as the initial template arguments to
        normalize_expression.
        (get_normalized_constraints_from_info): Remove 'args' parameter
        and adjust the call to get_normalized_constraints.
        (get_normalized_constraints_from_decl): Remove 'args' local
        variable and adjust call to get_normalized_constraints_from_info.
        (normalize_concept_definition): Remove 'args' local variable
        and adjust call to get_normalized_constraints.
        (normalize_constraint_expression): Remove the two-argument
        overload.  Remove 'args' parameter from the three-argument
        overload and update function comment accordingly.  Remove
        default argument from 'diag' parameter. Adjust call to
        get_normalized_constraints accordingly.
        (finish_nested_requirement): Adjust call to
        normalize_constraint_expression accordingly.
        (strictly_subsumes): Remove 'args' parameter.  Adjust call to
        get_normalized_constraints_from_info accordingly.
        (weakly_subsumes): Likewise.
        * cp-tree.h (strictly_subsumes): Remove 'args' parameter.
        (weakly_subsumes): Likewise.
        * pt.c (process_partial_specialization): Adjust call to
        strictly_subsumes accordingly.
        (is_compatible_template_arg): Adjust call to weakly_subsumes
        accordingly.
---
  gcc/cp/constraint.cc | 69 +++++++++++++-------------------------------
  gcc/cp/cp-tree.h     |  4 +--
  gcc/cp/pt.c          |  5 ++--
  3 files changed, 24 insertions(+), 54 deletions(-)

diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 75457a2dd60..d6354edbe6f 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -759,20 +759,18 @@ normalize_expression (tree t, tree args, norm_info info)
  static GTY((deletable)) hash_map<tree,tree> *normalized_map;
static tree
-get_normalized_constraints (tree t, tree args, norm_info info)
+get_normalized_constraints (tree t, norm_info info)
  {
    auto_timevar time (TV_CONSTRAINT_NORM);
-  return normalize_expression (t, args, info);
+  return normalize_expression (t, NULL_TREE, info);
  }
/* Returns the normalized constraints from a constraint-info object
-   or NULL_TREE if the constraints are null. ARGS provide the initial
-   arguments for normalization and IN_DECL provides the declaration
-   to which the constraints belong.  */
+   or NULL_TREE if the constraints are null. IN_DECL provides the
+   declaration to which the constraints belong.  */
static tree
-get_normalized_constraints_from_info (tree ci, tree args, tree in_decl,
-                                     bool diag = false)
+get_normalized_constraints_from_info (tree ci, tree in_decl, bool diag = false)
  {
    if (ci == NULL_TREE)
      return NULL_TREE;
@@ -780,8 +778,7 @@ get_normalized_constraints_from_info (tree ci, tree args, 
tree in_decl,
    /* Substitution errors during normalization are fatal.  */
    ++processing_template_decl;
    norm_info info (in_decl, diag ? tf_norm : tf_none);
-  tree t = get_normalized_constraints (CI_ASSOCIATED_CONSTRAINTS (ci),
-                                      args, info);
+  tree t = get_normalized_constraints (CI_ASSOCIATED_CONSTRAINTS (ci), info);
    --processing_template_decl;
return t;
@@ -843,9 +840,8 @@ get_normalized_constraints_from_decl (tree d, bool diag = 
false)
push_nested_class_guard pncs (DECL_CONTEXT (d)); - tree args = generic_targs_for (tmpl);
    tree ci = get_constraints (decl);
-  tree norm = get_normalized_constraints_from_info (ci, args, tmpl, diag);
+  tree norm = get_normalized_constraints_from_info (ci, tmpl, diag);
if (!diag)
      hash_map_safe_put<hm_ggc> (normalized_map, tmpl, norm);
@@ -866,11 +862,10 @@ normalize_concept_definition (tree tmpl, bool diag = 
false)
    if (OVL_P (tmpl))
      tmpl = OVL_FIRST (tmpl);
    gcc_assert (TREE_CODE (tmpl) == TEMPLATE_DECL);
-  tree args = generic_targs_for (tmpl);
    tree def = get_concept_definition (DECL_TEMPLATE_RESULT (tmpl));
    ++processing_template_decl;
    norm_info info (tmpl, diag ? tf_norm : tf_none);
-  tree norm = get_normalized_constraints (def, args, info);
+  tree norm = get_normalized_constraints (def, info);
    --processing_template_decl;
if (!diag)
@@ -895,42 +890,20 @@ normalize_nontemplate_requirements (tree decl, bool diag 
= false)
    return get_normalized_constraints_from_decl (decl, diag);
  }
-/* Normalize an EXPR as a constraint using ARGS. */
+/* Normalize an EXPR as a constraint.  */
static tree
-normalize_constraint_expression (tree expr, tree args, bool diag = false)
+normalize_constraint_expression (tree expr, bool diag)
  {
    if (!expr || expr == error_mark_node)
      return expr;
    ++processing_template_decl;
    norm_info info (diag ? tf_norm : tf_none);
-  tree norm = get_normalized_constraints (expr, args, info);
+  tree norm = get_normalized_constraints (expr, info);
    --processing_template_decl;
    return norm;
  }
-/* Normalize an EXPR as a constraint. */
-
-static tree
-normalize_constraint_expression (tree expr, bool diag = false)
-{
-  if (!expr || expr == error_mark_node)
-    return expr;
-
-  /* For concept checks, use the supplied template arguments as those used
-     for normalization. Otherwise, there are no template arguments.  */
-  tree args;
-  if (concept_check_p (expr))
-    {
-      tree id = unpack_concept_check (expr);
-      args = TREE_OPERAND (id, 1);
-    }
-  else
-    args = NULL_TREE;
-
-  return normalize_constraint_expression (expr, args, diag);
-}
-
  /* 17.4.1.2p2. Two constraints are identical if they are formed
     from the same expression and the targets of the parameter mapping
     are equivalent.  */
@@ -2998,9 +2971,7 @@ finish_compound_requirement (location_t loc, tree expr, 
tree type, bool noexcept
  tree
  finish_nested_requirement (location_t loc, tree expr)
  {
-  /* Currently open template headers have dummy arg vectors, so don't
-     pass into normalization.  */
-  tree norm = normalize_constraint_expression (expr, NULL_TREE, false);
+  tree norm = normalize_constraint_expression (expr, false);
/* Build the constraint, saving its normalization as its type. */
    tree r = build1 (NESTED_REQ, norm, expr);
@@ -3105,25 +3076,25 @@ subsumes_constraints (tree a, tree b)
    return subsumes (a, b);
  }
-/* Returns true when the constraints in CI (with arguments
-   ARGS) strictly subsume the associated constraints of TMPL.  */
+/* Returns true when the constraints in CI strictly subsume
+   the associated constraints of TMPL.  */
bool
-strictly_subsumes (tree ci, tree args, tree tmpl)
+strictly_subsumes (tree ci, tree tmpl)
  {
-  tree n1 = get_normalized_constraints_from_info (ci, args, NULL_TREE);
+  tree n1 = get_normalized_constraints_from_info (ci, NULL_TREE);
    tree n2 = get_normalized_constraints_from_decl (tmpl);
return subsumes (n1, n2) && !subsumes (n2, n1);
  }
-/* REturns true when the constraints in CI (with arguments ARGS) subsume
-   the associated constraints of TMPL.  */
+/* Returns true when the constraints in CI subsume the
+   associated constraints of TMPL.  */
bool
-weakly_subsumes (tree ci, tree args, tree tmpl)
+weakly_subsumes (tree ci, tree tmpl)
  {
-  tree n1 = get_normalized_constraints_from_info (ci, args, NULL_TREE);
+  tree n1 = get_normalized_constraints_from_info (ci, NULL_TREE);
    tree n2 = get_normalized_constraints_from_decl (tmpl);
return subsumes (n1, n2);
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 5c06ac3789e..3bea3381602 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -7838,8 +7838,8 @@ extern tree find_template_parameters              (tree, 
tree);
  extern bool equivalent_constraints              (tree, tree);
  extern bool equivalently_constrained            (tree, tree);
  extern bool subsumes_constraints                (tree, tree);
-extern bool strictly_subsumes                  (tree, tree, tree);
-extern bool weakly_subsumes                    (tree, tree, tree);
+extern bool strictly_subsumes                  (tree, tree);
+extern bool weakly_subsumes                    (tree, tree);
  extern int more_constrained                     (tree, tree);
  extern bool at_least_as_constrained             (tree, tree);
  extern bool constraints_equivalent_p            (tree, tree);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index dc664ec3798..e8864dffe3d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5089,8 +5089,7 @@ process_partial_specialization (tree decl)
      = TI_ARGS (get_template_info (DECL_TEMPLATE_RESULT (maintmpl)));
    if (comp_template_args (inner_args, INNERMOST_TEMPLATE_ARGS (main_args))
        && (!flag_concepts
-         || !strictly_subsumes (current_template_constraints (),
-                                main_args, maintmpl)))
+         || !strictly_subsumes (current_template_constraints (), maintmpl)))
      {
        if (!flag_concepts)
          error ("partial specialization %q+D does not specialize "
@@ -8163,7 +8162,7 @@ is_compatible_template_arg (tree parm, tree arg)
          return false;
      }
- return weakly_subsumes (parm_cons, new_args, arg);
+  return weakly_subsumes (parm_cons, arg);
  }
// Convert a placeholder argument into a binding to the original


Reply via email to