aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-03-31 17:34:47 -0400
committerJason Merrill <jason@redhat.com>2020-04-01 01:17:23 -0400
commit76f09260b7eccd6c3cfa3dcf3c22897fe12a8065 (patch)
treed51c2df1204ac7e061b58945552282bbcb104167 /gcc/cp/constexpr.c
parent595f1b1274b1cb86c74c72b9cc297e6981fe4549 (diff)
downloadgcc-76f09260b7eccd6c3cfa3dcf3c22897fe12a8065.zip
gcc-76f09260b7eccd6c3cfa3dcf3c22897fe12a8065.tar.gz
gcc-76f09260b7eccd6c3cfa3dcf3c22897fe12a8065.tar.bz2
c++: Fix DMI with lambda 'this' capture [PR94205]
We represent 'this' in a default member initializer with a PLACEHOLDER_EXPR. Normally in constexpr evaluation when we encounter one it refers to ctx->ctor, but when we're creating a temporary of class type, that replaces ctx->ctor, so a PLACEHOLDER_EXPR that refers to the type of the member being initialized needs to be replaced before that happens. gcc/cp/ChangeLog 2020-03-31 Jason Merrill <jason@redhat.com> PR c++/94205 * constexpr.c (cxx_eval_constant_expression) [TARGET_EXPR]: Call replace_placeholders. * typeck2.c (store_init_value): Fix arguments to fold_non_dependent_expr.
Diffstat (limited to 'gcc/cp/constexpr.c')
-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 e85b3c1..91f0c3b 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -5553,6 +5553,12 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
tree init = TARGET_EXPR_INITIAL (t);
if ((AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type)))
{
+ if (ctx->object)
+ /* If the initializer contains any PLACEHOLDER_EXPR, we need to
+ resolve them before we create a new CONSTRUCTOR for the
+ temporary. */
+ init = replace_placeholders (init, ctx->object);
+
/* We're being expanded without an explicit target, so start
initializing a new object; expansion with an explicit target
strips the TARGET_EXPR before we get here. */