aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constraint.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2022-11-15 09:32:21 -0500
committerPatrick Palka <ppalka@redhat.com>2022-11-15 09:32:21 -0500
commit5925f0ec54ab5ed773935eec09a602f58fa0ca2c (patch)
treefc38375379d93d0a5e7abe1b1a2aeb868ecc268e /gcc/cp/constraint.cc
parentc52c322627dd0f206b4bf7f7c94ab42bf5e61b6f (diff)
downloadgcc-5925f0ec54ab5ed773935eec09a602f58fa0ca2c.zip
gcc-5925f0ec54ab5ed773935eec09a602f58fa0ca2c.tar.gz
gcc-5925f0ec54ab5ed773935eec09a602f58fa0ca2c.tar.bz2
c++: remove i_c_e_p parm from tsubst_copy_and_build
It seems the only and original purpose of tsubst_copy_and_build's integral_constant_expression_p boolean parameter (added in r116276, which predates the constexpr machinery) is to diagnose certain constructs that aren't allowed to appear in a C++98 integral constant expression context, specifically casts to a non-integral type (diagnosed from the *_CAST_EXPR case of tsubst_copy_and_build) or dependent names that resolve to a non-constant decl (diagnosed from the IDENTIFIER_NODE case of tsubst_copy_and_build). The parameter has no effect outside of C++98 AFAICT. But diagnosing such constructs should arguably be the job of the constexpr machinery (e.g. is_constant_expression) after substitution, and doing it during substitution by way of an additional parameter complicates the API of this workhorse function for what amounts to a couple of archaic C++98 restrictions. And it seems is_constant_expression already does a good job of diagnosing the aforementioned two constructs in C++98 mode, at least as far as our testsuite is concerned. So this patch removes this parameter from tsubst_copy_and_build, tsubst_expr and tsubst_copy_and_build_call_args. The only interesting changes are to potential_constant_expression_1 and the IDENTIFIER_NODE and *_CAST_EXPR cases of tsubst_copy_and_build; the rest are mechanical adjustments to the functions' signatures and their call sites. gcc/cp/ChangeLog: * constexpr.cc (potential_constant_expression_1) <case *_CAST_EXPR>: Use cast_valid_in_integral_constant_expression_p instead of open coding it. * constraint.cc (tsubst_valid_expression_requirement): Adjust calls to tsubst_copy_and_build and tsubst_expr. (tsubst_constraint): Likewise. (satisfy_atom): Likewise. (diagnose_trait_expr): Likewise. * cp-tree.h (tsubst_copy_and_build): Remove i_c_e_p parameter. (tsubst_expr): Likewise. * init.cc (get_nsdmi): Adjust calls to tsubst_copy_and_build and tsubst_expr. * pt.cc (expand_integer_pack): Likewise. (instantiate_non_dependent_expr_internal): Likewise. (tsubst_friend_function): Likewise. (tsubst_attribute): Likewise. (instantiate_class_template): Likewise. (tsubst_template_arg): Likewise. (gen_elem_of_pack_expansion_instantiation): Likewise. (tsubst_fold_expr_init): Likewise. (tsubst_pack_expansion): Likewise. (tsubst_default_argument): Likewise. (tsubst_function_decl): Likewise. (tsubst_decl): Likewise. (tsubst_arg_types): Likewise. (tsubst_exception_specification): Likewise. (tsubst): Likewise. (tsubst_init): Likewise. (tsubst_copy): Likewise. (tsubst_omp_clause_decl): Likewise. (tsubst_omp_clauses): Likewise. (tsubst_copy_asm_operands): Likewise. (tsubst_omp_for_iterator): Likewise. (tsubst_expr): Likewise. Remove i_c_e_p parameter. (tsubst_omp_udr): Likewise. (tsubst_non_call_postfix_expression): Likewise. Remove i_c_e_p parameter. (tsubst_lambda_expr): Likewise. (tsubst_copy_and_build_call_args): Likewise. (tsubst_copy_and_build): Likewise. Remove i_c_e_p parameter. <case IDENTIFIER_NODE>: Adjust call to finish_id_expression following removal of i_c_e_p. <case *_CAST_EXPR>: Remove C++98-specific cast validity check guarded by i_c_e_p. (maybe_instantiate_noexcept): Adjust calls to tsubst_copy_and_build and tsubst_expr. (instantiate_body): Likewise. (instantiate_decl): Likewise. (tsubst_initializer_list): Likewise. (tsubst_enum): Likewise. gcc/objcp/ChangeLog: * objcp-lang.cc (objcp_tsubst_copy_and_build): Adjust calls to tsubst_copy_and_build and tsubst_expr. gcc/testsuite/ChangeLog: * g++.dg/template/crash55.C: Don't expect additional C++98-specific diagnostics. * g++.dg/template/ref3.C: Remove C++98-specific xfail.
Diffstat (limited to 'gcc/cp/constraint.cc')
-rw-r--r--gcc/cp/constraint.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index f6ef078..3ddbd53 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -1921,7 +1921,7 @@ hash_placeholder_constraint (tree c)
static tree
tsubst_valid_expression_requirement (tree t, tree args, sat_info info)
{
- tree r = tsubst_expr (t, args, tf_none, info.in_decl, false);
+ tree r = tsubst_expr (t, args, tf_none, info.in_decl);
if (convert_to_void (r, ICV_STATEMENT, tf_none) != error_mark_node)
return r;
@@ -1932,7 +1932,7 @@ tsubst_valid_expression_requirement (tree t, tree args, sat_info info)
{
inform (loc, "the required expression %qE is invalid, because", t);
if (r == error_mark_node)
- tsubst_expr (t, args, info.complain, info.in_decl, false);
+ tsubst_expr (t, args, info.complain, info.in_decl);
else
convert_to_void (r, ICV_STATEMENT, info.complain);
}
@@ -1941,7 +1941,7 @@ tsubst_valid_expression_requirement (tree t, tree args, sat_info info)
}
else if (info.noisy ())
{
- r = tsubst_expr (t, args, info.complain, info.in_decl, false);
+ r = tsubst_expr (t, args, info.complain, info.in_decl);
convert_to_void (r, ICV_STATEMENT, info.complain);
}
@@ -2706,7 +2706,7 @@ tsubst_constraint (tree t, tree args, tsubst_flags_t complain, tree in_decl)
constraint-expressions of a declaration. */
processing_constraint_expression_sentinel s;
cp_unevaluated u;
- tree expr = tsubst_expr (t, args, complain, in_decl, false);
+ tree expr = tsubst_expr (t, args, complain, in_decl);
return expr;
}
@@ -2954,13 +2954,13 @@ satisfy_atom (tree t, tree args, sat_info info)
/* Apply the parameter mapping (i.e., just substitute). */
tree expr = ATOMIC_CONSTR_EXPR (t);
- tree result = tsubst_expr (expr, args, quiet.complain, quiet.in_decl, false);
+ tree result = tsubst_expr (expr, args, quiet.complain, quiet.in_decl);
if (result == error_mark_node)
{
/* If substitution results in an invalid type or expression, the constraint
is not satisfied. Replay the substitution. */
if (info.diagnose_unsatisfaction_p ())
- tsubst_expr (expr, args, info.complain, info.in_decl, false);
+ tsubst_expr (expr, args, info.complain, info.in_decl);
return cache.save (inst_cache.save (boolean_false_node));
}
@@ -3587,7 +3587,7 @@ diagnose_trait_expr (tree expr, tree args)
/* Build a "fake" version of the instantiated trait, so we can
get the instantiated types from result. */
++processing_template_decl;
- expr = tsubst_expr (expr, args, tf_none, NULL_TREE, false);
+ expr = tsubst_expr (expr, args, tf_none, NULL_TREE);
--processing_template_decl;
tree t1 = TRAIT_EXPR_TYPE1 (expr);