aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-01-04 16:11:08 -0500
committerJason Merrill <jason@redhat.com>2021-01-07 16:09:11 -0500
commit6c59b8a93cf4784e3e3137416a3d32a1ecc8e00b (patch)
treef118a0ed3863ae888ed200d795385bce6cbd20d3
parent4d65a07d54bd9371475648f7de9d4b6a01238813 (diff)
downloadgcc-6c59b8a93cf4784e3e3137416a3d32a1ecc8e00b.zip
gcc-6c59b8a93cf4784e3e3137416a3d32a1ecc8e00b.tar.gz
gcc-6c59b8a93cf4784e3e3137416a3d32a1ecc8e00b.tar.bz2
c++: Add TARGET_EXPR comments
Discussing the 98469 patch and class prvalues with Jakub led me to double-check our handling of TARGET_EXPR in constexpr.c, and add a note about why we don't strip them in parameter initialization. And another to clarify that we're handling an INIT_EXPR in a place we do strip them. gcc/cp/ChangeLog: * constexpr.c (cxx_bind_parameters_in_call): Add comment. (cxx_eval_store_expression): Add comment.
-rw-r--r--gcc/cp/constexpr.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 0c12f60..4a5e638 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -1591,6 +1591,9 @@ cxx_bind_parameters_in_call (const constexpr_ctx *ctx, tree t,
if (TREE_ADDRESSABLE (type))
/* Undo convert_for_arg_passing work here. */
x = convert_from_reference (x);
+ /* Normally we would strip a TARGET_EXPR in an initialization context
+ such as this, but here we do the elision differently: we keep the
+ TARGET_EXPR, and use its CONSTRUCTOR as the value of the parm. */
arg = cxx_eval_constant_expression (ctx, x, /*lval=*/false,
non_constant_p, overflow_p);
/* Don't VERIFY_CONSTANT here. */
@@ -5388,6 +5391,9 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t,
if (!preeval)
{
+ /* We're handling an INIT_EXPR of class type, so the value of the
+ initializer can depend on the object it's initializing. */
+
/* Create a new CONSTRUCTOR in case evaluation of the initializer
wants to modify it. */
if (*valp == NULL_TREE)