On 10/15/24 12:45 AM, Patrick Palka wrote:
This patch further cleans up the concepts code following the removal of
Concepts TS support:

   * concept-ids are now the only kind of "concept check", so we can
     simplify some code accordingly.  In particular resolve_concept_check
     seems like a no-op and can be removed.
   * In turn, deduce_constrained_parameter doesn't seem to do anything
     interesting.
   * In light of the above we might as well inline finish_type_constraints
     into its only caller.  Note that the "prototype parameter" of a
     concept is just the first template parameter which the caller can
     easily obtain itself.

But it's still a defined term in the language (https://eel.is/c++draft/temp#concept-7) so I think it's worth having an accessor function. I agree with doing away with the function that returns a pair.

   * placeholder_extract_concept_and_args is only ever called on a
     concept-id, so it's simpler to inline it into its callers.
   * There's no such thing as a template-template-parameter wtih a
     type-constraint, so we can remove such handling from the parser.
     This means is_constrained_parameter is currently equivalent to
     declares_constrained_template_template_parameter, so let's prefer
     to use the latter.

Why prefer the longer name?

We might be able to remove WILDCARD_DECL and CONSTRAINED_PARM_PROTOTYPE
now as well, but I left that as future work.

@@ -18901,7 +18842,8 @@ cp_parser_template_parameter (cp_parser* parser, bool 
*is_non_type,
      }
/* The parameter may have been constrained type parameter. */
-  if (is_constrained_parameter (parameter_declarator))
+  tree type = parameter_declarator->decl_specifiers.type;
+  if (declares_constrained_type_template_parameter (type))

Why not retain a function that takes the declarator?

      return finish_constrained_parameter (parser,
                                           parameter_declarator,
                                           is_non_type);
@@ -20987,11 +20929,12 @@ cp_parser_placeholder_type_specifier (cp_parser 
*parser, location_t loc,
    tsubst_flags_t complain = tentative ? tf_none : tf_warning_or_error;
/* Get the concept and prototype parameter for the constraint. */
-  tree_pair info = finish_type_constraints (tmpl, args, complain);
-  tree con = info.first;
-  tree proto = info.second;
-  if (con == error_mark_node)
+  tree check = build_type_constraint (tmpl, args, complain);
+  if (check == error_mark_node)
      return error_mark_node;
+  tree con = STRIP_TEMPLATE (tmpl);
+  tree parms = DECL_INNERMOST_TEMPLATE_PARMS (tmpl);
+  tree proto = TREE_VALUE (TREE_VEC_ELT (parms, 0));

And as mentioned above, let's have a small function that returns the prototype parameter of a concept, to use here.

Incidentally, why do we want to strip the template from con? Is that also a relic of the different possible forms of concept?

Jason

Reply via email to