From 935e82248873c3798d4ede742a75ad10e99257ad Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 1 Aug 2024 15:39:10 -0400 Subject: c++: remove function/var concepts code This patch removes vestigial Concepts TS code as discussed in . 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. Simplify. * 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) : 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/parser.cc | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'gcc/cp/parser.cc') diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index eb102de..f625b0a 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -7161,18 +7161,13 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, tree fns = get_fns (tid); if (OVL_SINGLE_P (fns)) tmpl = OVL_FIRST (fns); - if (function_concept_p (fns)) - error_at (token->location, "concept-id %qD " - "in nested-name-specifier", tid); - else - error_at (token->location, "function template-id " - "%qD in nested-name-specifier", tid); + error_at (token->location, "function template-id " + "%qD in nested-name-specifier", tid); } else { tmpl = TREE_OPERAND (tid, 0); - if (variable_concept_p (tmpl) - || standard_concept_p (tmpl)) + if (concept_definition_p (tmpl)) error_at (token->location, "concept-id %qD " "in nested-name-specifier", tid); else @@ -12224,9 +12219,6 @@ add_debug_begin_stmt (location_t loc) { if (!MAY_HAVE_DEBUG_MARKER_STMTS) return; - if (DECL_DECLARED_CONCEPT_P (current_function_decl)) - /* A concept is never expanded normally. */ - return; tree stmt = build0 (DEBUG_BEGIN_STMT, void_type_node); SET_EXPR_LOCATION (stmt, loc); @@ -33087,8 +33079,6 @@ cp_parser_template_declaration_after_parameters (cp_parser* parser, else if (flag_concepts && cp_lexer_next_token_is_keyword (parser->lexer, RID_CONCEPT) && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME)) - /* -fconcept-ts 'concept bool' syntax is handled below, in - cp_parser_single_declaration. */ decl = cp_parser_concept_definition (parser); else { -- cgit v1.1