aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/pt.cc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2024-08-01 15:39:10 -0400
committerMarek Polacek <polacek@redhat.com>2024-08-05 20:56:31 -0400
commit935e82248873c3798d4ede742a75ad10e99257ad (patch)
tree848f80a1101c6e281669ac4cc2e59d8144914a6f /gcc/cp/pt.cc
parent8ac4db24e43b09726f87f04213f782dce1b3ae47 (diff)
downloadgcc-935e82248873c3798d4ede742a75ad10e99257ad.zip
gcc-935e82248873c3798d4ede742a75ad10e99257ad.tar.gz
gcc-935e82248873c3798d4ede742a75ad10e99257ad.tar.bz2
c++: remove function/var concepts code
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. 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) <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.
Diffstat (limited to 'gcc/cp/pt.cc')
-rw-r--r--gcc/cp/pt.cc60
1 files changed, 6 insertions, 54 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 77fa590..35a9c56 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -3232,14 +3232,6 @@ check_explicit_specialization (tree declarator,
tree tmpl_func = DECL_TEMPLATE_RESULT (gen_tmpl);
gcc_assert (TREE_CODE (tmpl_func) == FUNCTION_DECL);
- /* A concept cannot be specialized. */
- if (DECL_DECLARED_CONCEPT_P (tmpl_func))
- {
- error ("explicit specialization of function concept %qD",
- gen_tmpl);
- return error_mark_node;
- }
-
/* This specialization has the same linkage and visibility as
the function template it specializes. */
TREE_PUBLIC (decl) = TREE_PUBLIC (tmpl_func);
@@ -5150,13 +5142,6 @@ process_partial_specialization (tree decl)
gcc_assert (current_template_parms);
- /* A concept cannot be specialized. */
- if (flag_concepts && variable_concept_p (maintmpl))
- {
- error ("specialization of variable concept %q#D", maintmpl);
- return error_mark_node;
- }
-
inner_parms = INNERMOST_TEMPLATE_PARMS (current_template_parms);
ntparms = TREE_VEC_LENGTH (inner_parms);
@@ -10532,9 +10517,6 @@ lookup_template_class (tree d1, tree arglist, tree in_decl, tree context,
tree
lookup_template_variable (tree templ, tree arglist, tsubst_flags_t complain)
{
- if (flag_concepts && variable_concept_p (templ))
- return build_concept_check (templ, arglist, tf_none);
-
tree gen_templ = most_general_template (templ);
tree parms = DECL_INNERMOST_TEMPLATE_PARMS (gen_templ);
arglist = add_outermost_template_args (templ, arglist);
@@ -20119,14 +20101,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
tree check = build_concept_check (templ, targs, complain);
if (check == error_mark_node)
RETURN (error_mark_node);
-
- tree id = unpack_concept_check (check);
-
- /* If we built a function concept check, return the underlying
- template-id. So we can evaluate it as a function call. */
- if (function_concept_p (TREE_OPERAND (id, 0)))
- RETURN (id);
-
RETURN (check);
}
@@ -21096,19 +21070,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
ret = build_offset_ref_call_from_tree (function, &call_args,
complain);
else if (concept_check_p (function))
- {
- /* FUNCTION is a template-id referring to a concept definition. */
- tree id = unpack_concept_check (function);
- tree tmpl = TREE_OPERAND (id, 0);
- tree args = TREE_OPERAND (id, 1);
-
- /* Calls to standard and variable concepts should have been
- previously diagnosed. */
- gcc_assert (function_concept_p (tmpl));
-
- /* Ensure the result is wrapped as a call expression. */
- ret = build_concept_check (tmpl, args, tf_warning_or_error);
- }
+ /* Calls to concepts should have been previously diagnosed. */
+ gcc_assert (false);
else
ret = finish_call_expr (function, &call_args,
/*disallow_virtual=*/qualified_p,
@@ -26414,14 +26377,6 @@ do_decl_instantiation (tree decl, tree storage)
error ("explicit instantiation of non-template %q#D", decl);
return;
}
- else if (DECL_DECLARED_CONCEPT_P (decl))
- {
- if (VAR_P (decl))
- error ("explicit instantiation of variable concept %q#D", decl);
- else
- error ("explicit instantiation of function concept %q#D", decl);
- return;
- }
bool var_templ = (DECL_TEMPLATE_INFO (decl)
&& variable_template_p (DECL_TI_TEMPLATE (decl)));
@@ -27211,9 +27166,6 @@ instantiate_decl (tree d, bool defer_ok, bool expl_inst_class_mem_p)
functions and static member variables. */
gcc_assert (VAR_OR_FUNCTION_DECL_P (d));
- /* A concept is never instantiated. */
- gcc_assert (!DECL_DECLARED_CONCEPT_P (d));
-
gcc_checking_assert (!DECL_FUNCTION_SCOPE_P (d));
if (modules_p ())
@@ -29492,8 +29444,8 @@ make_constrained_decltype_auto (tree con, tree args)
static bool
placeholder_type_constraint_dependent_p (tree t)
{
- tree id = unpack_concept_check (t);
- tree args = TREE_OPERAND (id, 1);
+ gcc_assert (concept_check_p (t));
+ tree args = TREE_OPERAND (t, 1);
tree first = TREE_VEC_ELT (args, 0);
if (ARGUMENT_PACK_P (first))
{
@@ -31452,8 +31404,8 @@ convert_generic_types_to_packs (tree parm, int start_idx, int end_idx)
requirements. */
if (tree constr = TEMPLATE_PARM_CONSTRAINTS (node))
{
- tree id = unpack_concept_check (constr);
- TREE_VEC_ELT (TREE_OPERAND (id, 1), 0) = t;
+ gcc_assert (concept_check_p (constr));
+ TREE_VEC_ELT (TREE_OPERAND (constr, 1), 0) = t;
/* Use UNKNOWN_LOCATION so write_template_args can tell the
difference between this and a fold the user wrote. */
location_t loc = UNKNOWN_LOCATION;