PR c++/93280 - ICE with aggregate assignment and DMI.
authorJason Merrill <jason@redhat.com>
Thu, 16 Jan 2020 15:46:40 +0000 (10:46 -0500)
committerJason Merrill <jason@redhat.com>
Thu, 16 Jan 2020 22:40:15 +0000 (17:40 -0500)
commit801f5b96775288e55193a66a746caab1ddd56f4a
tree4ca550165104863c6e01a704dfb637864051b2bf
parentf48c6014133c8989702458f9082e34ba6dd326d4
PR c++/93280 - ICE with aggregate assignment and DMI.

I recently added an assert to cp-gimplify to catch any
TARGET_EXPR_DIRECT_INIT_P being expanded without a target object, and this
testcase found one.  We started out with a TARGET_EXPR around the
CONSTRUCTOR, which would normally mean that the member initializer would be
used to directly initialize the appropriate member of whatever object the
TARGET_EXPR ends up initializing.  But then gimplify_modify_expr_rhs
stripped the TARGET_EXPR in order to assign directly from the elements of
the CONSTRUCTOR, leaving no object for the TARGET_EXPR_DIRECT_INIT_P to
initialize.  I considered setting CONSTRUCTOR_PLACEHOLDER_BOUNDARY in that
case, which implies TARGET_EXPR_NO_ELIDE, but decided that there's no
particular reason the A initializer needs to initialize a member of a B
rather than a distinct A object, so let's only set TARGET_EXPR_DIRECT_INIT_P
when we're using the DMI in a constructor.

* init.c (get_nsdmi): Set TARGET_EXPR_DIRECT_INIT_P here.
* typeck2.c (digest_nsdmi_init): Not here.
gcc/cp/ChangeLog
gcc/cp/init.c
gcc/cp/typeck2.c