diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-11-15 09:32:21 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-11-15 09:32:21 -0500 |
commit | 5925f0ec54ab5ed773935eec09a602f58fa0ca2c (patch) | |
tree | fc38375379d93d0a5e7abe1b1a2aeb868ecc268e /gcc/cp/init.cc | |
parent | c52c322627dd0f206b4bf7f7c94ab42bf5e61b6f (diff) | |
download | gcc-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/init.cc')
-rw-r--r-- | gcc/cp/init.cc | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index fee4909..2fff4ad 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -620,10 +620,8 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain) start_lambda_scope (member); /* Do deferred instantiation of the NSDMI. */ - init = (tsubst_copy_and_build - (init, DECL_TI_ARGS (member), - complain, member, - /*integral_constant_expression_p=*/false)); + init = tsubst_copy_and_build (init, DECL_TI_ARGS (member), + complain, member); init = digest_nsdmi_init (member, init, complain); finish_lambda_scope (); |