aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2023-10-20 10:45:00 -0400
committerPatrick Palka <ppalka@redhat.com>2023-10-20 10:45:00 -0400
commitdad311874ac3b3cf4eca1c04f67cae80c953f7b8 (patch)
treefe3872c2053d84288e5bdf1986e8f365bc700761 /gcc/cp/constexpr.cc
parenteb15fad3190a8b33e3e451b964ff1ecf08bbb113 (diff)
downloadgcc-dad311874ac3b3cf4eca1c04f67cae80c953f7b8.zip
gcc-dad311874ac3b3cf4eca1c04f67cae80c953f7b8.tar.gz
gcc-dad311874ac3b3cf4eca1c04f67cae80c953f7b8.tar.bz2
c++: remove NON_DEPENDENT_EXPR, part 1
This tree code dates all the way back to r69130[1] which implemented typing of non-dependent expressions. Its motivation was never clear (to me at least) since its documentation in e.g. cp-tree.def doesn't seem accurate anymore. build_non_dependent_expr has since gained a bunch of edge cases about whether or how to wrap certain templated trees, making it hard to reason about in general. So this patch removes this tree code, and temporarily turns build_non_dependent_expr into the identity function. The subsequent patch will remove build_non_dependent_expr and adjust its callers appropriately. We now need to more thoroughly handle templated (sub)trees in a couple of places which previously didn't need to since they didn't look through NON_DEPENDENT_EXPR. [1]: https://gcc.gnu.org/pipermail/gcc-patches/2003-July/109355.html gcc/c-family/ChangeLog: * c-warn.cc (check_address_or_pointer_of_packed_member): Handle type-dependent callee of CALL_EXPR. gcc/cp/ChangeLog: * class.cc (instantiate_type): Remove NON_DEPENDENT_EXPR handling. * constexpr.cc (cxx_eval_constant_expression): Likewise. (potential_constant_expression_1): Likewise. * coroutines.cc (coro_validate_builtin_call): Don't expect ALIGNOF_EXPR to be wrapped in NON_DEPENDENT_EXPR. * cp-objcp-common.cc (cp_common_init_ts): Remove NON_DEPENDENT_EXPR handling. * cp-tree.def (NON_DEPENDENT_EXPR): Remove. * cp-tree.h (build_non_dependent_expr): Temporarily redefine as the identity function. * cvt.cc (maybe_warn_nodiscard): Handle type-dependent and variable callee of CALL_EXPR. * cxx-pretty-print.cc (cxx_pretty_printer::expression): Remove NON_DEPENDENT_EXPR handling. * error.cc (dump_decl): Likewise. (dump_expr): Likewise. * expr.cc (mark_use): Likewise. (mark_exp_read): Likewise. * pt.cc (build_non_dependent_expr): Remove. * tree.cc (lvalue_kind): Remove NON_DEPENDENT_EXPR handling. (cp_stabilize_reference): Likewise. * typeck.cc (warn_for_null_address): Likewise. (cp_build_binary_op): Handle type-dependent SIZEOF_EXPR operands. (cp_build_unary_op) <case TRUTH_NOT_EXPR>: Don't fold inside a template. gcc/testsuite/ChangeLog: * g++.dg/concepts/var-concept3.C: Adjust expected diagnostic for attempting to call a variable concept. Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp/constexpr.cc')
-rw-r--r--gcc/cp/constexpr.cc9
1 files changed, 0 insertions, 9 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 6e84c2d..c05760e 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -8208,7 +8208,6 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
case MODOP_EXPR:
/* GCC internal stuff. */
case VA_ARG_EXPR:
- case NON_DEPENDENT_EXPR:
case BASELINK:
case OFFSET_REF:
if (!ctx->quiet)
@@ -10077,14 +10076,6 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
case BIND_EXPR:
return RECUR (BIND_EXPR_BODY (t), want_rval);
- case NON_DEPENDENT_EXPR:
- /* Treat NON_DEPENDENT_EXPR as non-constant: it's not handled by
- constexpr evaluation or tsubst, so fold_non_dependent_expr can't
- do anything useful with it. And we shouldn't see it in a context
- where a constant expression is strictly required, hence the assert. */
- gcc_checking_assert (!(flags & tf_error));
- return false;
-
case CLEANUP_POINT_EXPR:
case MUST_NOT_THROW_EXPR:
case TRY_CATCH_EXPR: