On 8/2/24 2:12 PM, Marek Polacek wrote:
Bootstrapped/regtested on x86_64-pc-linux-gnu. Comments?
-- >8 --
This patch removes vestigial Concepts TS code as discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657937.html>.
In particular, it removes code related to function/variable concepts.
That includes variable_concept_p and function_concept_p, which then
cascades into removing DECL_DECLARED_CONCEPT_P etc. So I think we
no longer need to say "standard concept" since there are no non-standard
ones anymore.
I've added two new errors saying that "variable/function concepts are
no longer supported".
gcc/cp/ChangeLog:
* constexpr.cc (cxx_eval_constant_expression): Don't call
unpack_concept_check. Add a concept_check_p assert. Remove
function_concept_p code.
* constraint.cc (check_constraint_atom): Remove function concepts code.
(unpack_concept_check): Remove.
(get_concept_check_template): Remove Concepts TS code.
(resolve_function_concept_overload): Remove.
(resolve_function_concept_check): Remove.
(resolve_concept_check): Remove Concepts TS code.
(get_returned_expression): Remove.
(get_variable_initializer): Remove.
(get_concept_definition): Remove Concepts TS code.
(normalize_concept_check): Likewise.
(build_function_check): Remove.
(build_variable_check): Remove.
(build_standard_check): Use concept_definition_p instead of
standard_concept_p.
(build_concept_check): Remove variable_concept_p/function_concept_p
code.
(build_concept_id): Simplify.
(build_type_constraint): Likewise.
(placeholder_extract_concept_and_args): Likewise.
(satisfy_nondeclaration_constraints): Likewise.
(check_function_concept): Remove.
(get_constraint_error_location): Remove Concepts TS code.
* cp-tree.h (DECL_DECLARED_CONCEPT_P): Remove.
(check_function_concept): Remove.
(unpack_concept_check): Remove.
(standard_concept_p): Remove.
(variable_concept_p): Remove.
(function_concept_p): Remove.
(concept_definition_p): Simplify.
(concept_check_p): Don't check for CALL_EXPR.
* decl.cc (check_concept_refinement): Remove.
(duplicate_decls): Remove check_concept_refinement code.
(is_concept_var): Remove.
(cp_finish_decl): Remove is_concept_var.
(check_concept_fn): Remove.
(grokfndecl): Give an error about function concepts not being supported
anymore. Remove unused code.
(grokvardecl): Give an error about variable concepts not being
supported anymore.
(finish_function): Remove DECL_DECLARED_CONCEPT_P code.
* decl2.cc (min_vis_expr_r): Use concept_definition_p instead of
standard_concept_p.
(maybe_instantiate_decl): Remove DECL_DECLARED_CONCEPT_P check.
(mark_used): Likewise.
* error.cc (dump_simple_decl): Use concept_definition_p instead of
standard_concept_p.
(dump_function_decl): Remove DECL_DECLARED_CONCEPT_P code.
(print_concept_check_info): Don't call unpack_concept_check.
* mangle.cc (write_type_constraint): Likewise.
* parser.cc (cp_parser_nested_name_specifier_opt): Remove
function_concept_p code. Only check concept_definition_p, not
variable_concept_p/standard_concept_p.
(add_debug_begin_stmt): Remove DECL_DECLARED_CONCEPT_P code.
(cp_parser_template_declaration_after_parameters): Remove a stale
comment.
* pt.cc (check_explicit_specialization): Remove
DECL_DECLARED_CONCEPT_P code.
(process_partial_specialization): Remove variable_concept_p code.
(lookup_template_variable): Likewise.
(tsubst_expr) <case CALL_EXPR>: Remove Concepts TS code and simplify.
(do_decl_instantiation): Remove DECL_DECLARED_CONCEPT_P code.
(instantiate_decl): Likewise.
(placeholder_type_constraint_dependent_p): Don't call
unpack_concept_check. Add a concept_check_p assert.
(convert_generic_types_to_packs): Likewise.
* semantics.cc (finish_call_expr): Remove Concepts TS code and simplify.
gcc/testsuite/ChangeLog:
* g++.dg/concepts/decl-diagnose.C: Adjust dg-error.
* g++.dg/concepts/fn-concept2.C: Likewise.
* g++.dg/concepts/pr71128.C: Likewise.
* g++.dg/concepts/var-concept6.C: Likewise.
* g++.dg/cpp2a/concepts.C: Likewise.
---
gcc/cp/constexpr.cc | 13 +-
gcc/cp/constraint.cc | 346 +-----------------
gcc/cp/cp-tree.h | 71 +---
gcc/cp/decl.cc | 118 +-----
gcc/cp/decl2.cc | 4 +-
gcc/cp/error.cc | 10 +-
gcc/cp/mangle.cc | 4 +-
gcc/cp/parser.cc | 16 +-
gcc/cp/pt.cc | 60 +--
gcc/cp/semantics.cc | 17 +-
gcc/testsuite/g++.dg/concepts/decl-diagnose.C | 8 +-
gcc/testsuite/g++.dg/concepts/fn-concept2.C | 4 +-
gcc/testsuite/g++.dg/concepts/pr71128.C | 8 +-
gcc/testsuite/g++.dg/concepts/var-concept6.C | 2 +-
gcc/testsuite/g++.dg/cpp2a/concepts.C | 4 +-
15 files changed, 65 insertions(+), 620 deletions(-)
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 8277b3b79ba..b079be1b3d5 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -8508,20 +8508,11 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx,
tree t,
{
/* We can evaluate template-id that refers to a concept only if
the template arguments are non-dependent. */
- tree id = unpack_concept_check (t);
- tree tmpl = TREE_OPERAND (id, 0);
+ gcc_assert (concept_check_p (t));
+ tree tmpl = TREE_OPERAND (t, 0);
if (!concept_definition_p (tmpl))
internal_error ("unexpected template-id %qE", t);
It seems unnecessary to have both the assert and the internal_error
here; I'd drop the internal_error.
-/* The normal form of an atom depends on the expression. The normal
- form of a function call to a function concept is a check constraint
- for that concept. The normal form of a reference to a variable
- concept is a check constraint for that concept. Otherwise, the
- constraint is a predicate constraint. */
+/* The normal form of an atom is a predicate constraint. */
I think the term "predicate constraint" is also obsolete; it's now
"atomic constraint".
@@ -3952,8 +3950,8 @@ print_concept_check_info (diagnostic_context *context,
tree expr, tree map, tree
{
gcc_assert (concept_check_p (expr));
- tree id = unpack_concept_check (expr);
- tree tmpl = TREE_OPERAND (id, 0);
+ tree tmpl = TREE_OPERAND (expr, 0);
+ // ??? Can this go now that fn/var concepts have been removed?
I would definitely expect so, did you try?
I think we also want to adjust the 'concept bool' handling in
cp_parser_decl_specifier_seq:
/* Warn for concept as a decl-specifier. We'll rewrite these as
concept declarations later. */
{
cp_token *next = cp_lexer_peek_token (parser->lexer);
if (next->keyword == RID_BOOL)
=> permerror (next->location, "the %<bool%> keyword is not "
"allowed in a C++20 concept definition");
else
error_at (token->location, "C++20 concept definition syntax "
"is %<concept <name> = <expr>%>");
}
After the permerror let's skip the 'bool' token and continue trying to
parse a concept declaration. I think that should allow us to remove
more of the code in grokfndecl/grokvardecl?
Jason