c++: Fix DMI with lambda 'this' capture [PR94205]
authorJason Merrill <jason@redhat.com>
Tue, 31 Mar 2020 21:34:47 +0000 (17:34 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 1 Apr 2020 05:17:23 +0000 (01:17 -0400)
commit76f09260b7eccd6c3cfa3dcf3c22897fe12a8065
treed51c2df1204ac7e061b58945552282bbcb104167
parent595f1b1274b1cb86c74c72b9cc297e6981fe4549
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.
gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/cp/tree.c
gcc/cp/typeck2.c
gcc/testsuite/g++.dg/cpp1y/constexpr-nsdmi2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/lambda-this4.C [new file with mode: 0644]