From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1888) id 128833858D1E; Tue, 13 Sep 2022 14:01:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 128833858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663077705; bh=jcqOhhsCZKi0yGSd4Mvi90DFFPnZ9OVYEMGu0Q6Uynk=; h=From:To:Subject:Date:From; b=OglwEHsLByur76SQbpx28gmMKRZwT/S5KfdTz9cfSHS1NvsAD1/WHAD77oVqizdRA TuFACNd25MP6Ymat2CFp7ow2++Kx8wkxmYWXs7oyGLWAZGOXyWjxEFSzHuAeHQe+xF 7zckhLbUnVWDLSqYykrFxrHVi3YqTlGH3ggr2Oxg= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Patrick Palka To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2646] c++: two-parameter version of cxx_constant_value X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/master X-Git-Oldrev: 441a4880cba0908e58a102b068095e4ac2bb46cc X-Git-Newrev: fea6ae0e5d82c01680c788c77709076b9288d145 Message-Id: <20220913140145.128833858D1E@sourceware.org> Date: Tue, 13 Sep 2022 14:01:45 +0000 (GMT) List-Id: https://gcc.gnu.org/g:fea6ae0e5d82c01680c788c77709076b9288d145 commit r13-2646-gfea6ae0e5d82c01680c788c77709076b9288d145 Author: Patrick Palka Date: Tue Sep 13 10:01:29 2022 -0400 c++: two-parameter version of cxx_constant_value Since some callers need the complain parameter but not the object parameter, let's introduce and use an overload of cxx_constant_value that omits the latter. gcc/cp/ChangeLog: * cp-tree.h (cxx_constant_value): Define two-parameter version that omits the object parameter. * decl.cc (build_explicit_specifier): Omit NULL_TREE object argument to cxx_constant_value. * except.cc (build_noexcept_spec): Likewise. * pt.cc (expand_integer_pack): Likewise. (fold_targs_r): Likewise. * semantics.cc (finish_if_stmt_cond): Likewise. Diff: --- gcc/cp/cp-tree.h | 2 ++ gcc/cp/decl.cc | 2 +- gcc/cp/except.cc | 2 +- gcc/cp/pt.cc | 4 ++-- gcc/cp/semantics.cc | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 2ba44e80e20..1eb176d4a50 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -8414,6 +8414,8 @@ extern bool require_rvalue_constant_expression (tree); extern bool require_potential_rvalue_constant_expression (tree); extern tree cxx_constant_value (tree, tree = NULL_TREE, tsubst_flags_t = tf_error); +inline tree cxx_constant_value (tree t, tsubst_flags_t complain) +{ return cxx_constant_value (t, NULL_TREE, complain); } extern void cxx_constant_dtor (tree, tree); extern tree cxx_constant_init (tree, tree = NULL_TREE); extern tree maybe_constant_value (tree, tree = NULL_TREE, bool = false); diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 5404d7e084c..006e9affcba 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -18557,7 +18557,7 @@ build_explicit_specifier (tree expr, tsubst_flags_t complain) expr = build_converted_constant_bool_expr (expr, complain); expr = instantiate_non_dependent_expr (expr, complain); - expr = cxx_constant_value (expr, NULL_TREE, complain); + expr = cxx_constant_value (expr, complain); return expr; } diff --git a/gcc/cp/except.cc b/gcc/cp/except.cc index 4d7f0ce102d..048612de400 100644 --- a/gcc/cp/except.cc +++ b/gcc/cp/except.cc @@ -1257,7 +1257,7 @@ build_noexcept_spec (tree expr, tsubst_flags_t complain) { expr = build_converted_constant_bool_expr (expr, complain); expr = instantiate_non_dependent_expr (expr, complain); - expr = cxx_constant_value (expr, NULL_TREE, complain); + expr = cxx_constant_value (expr, complain); } if (TREE_CODE (expr) == INTEGER_CST) { diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 074179288b6..db4e808adec 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -3869,7 +3869,7 @@ expand_integer_pack (tree call, tree args, tsubst_flags_t complain, else { hi = instantiate_non_dependent_expr (hi, complain); - hi = cxx_constant_value (hi, NULL_TREE, complain); + hi = cxx_constant_value (hi, complain); int len = valid_constant_size_p (hi) ? tree_to_shwi (hi) : -1; /* Calculate the largest value of len that won't make the size of the vec @@ -20121,7 +20121,7 @@ fold_targs_r (tree targs, tsubst_flags_t complain) && !glvalue_p (elt) && !TREE_CONSTANT (elt)) { - elt = cxx_constant_value (elt, NULL_TREE, complain); + elt = cxx_constant_value (elt, complain); if (elt == error_mark_node) return false; } diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 3edefb2fca2..4f189978484 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -1042,7 +1042,7 @@ finish_if_stmt_cond (tree orig_cond, tree if_stmt) { maybe_warn_for_constant_evaluated (cond, /*constexpr_if=*/true); cond = instantiate_non_dependent_expr (cond); - cond = cxx_constant_value (cond, NULL_TREE); + cond = cxx_constant_value (cond); } else {