https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90996

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>:

https://gcc.gnu.org/g:23f1f679141bbb4720ca195cb758605dc017b7fd

commit r10-7587-g23f1f679141bbb4720ca195cb758605dc017b7fd
Author: Patrick Palka <ppa...@redhat.com>
Date:   Mon Apr 6 14:05:44 2020 -0400

    c++: Fix usage of CONSTRUCTOR_PLACEHOLDER_BOUNDARY inside array
initializers [PR90996]

    This PR reports that ever since the introduction of the
    CONSTRUCTOR_PLACEHOLDER_BOUNDARY flag, we are sometimes failing to resolve
    PLACEHOLDER_EXPRs inside array initializers that refer to some inner
    constructor.  In the testcase in the PR, we have as the initializer for "S
c[];"
    the following

      {{.a=(int &) &_ZGR1c_, .b={*(&<PLACEHOLDER_EXPR struct S>)->a}}}

    where CONSTRUCTOR_PLACEHOLDER_BOUNDARY is set on the middle constructor. 
When
    calling replace_placeholders from store_init_value, we pass the entire
    initializer to it, and as a result we fail to resolve the PLACEHOLDER_EXPR
    within due to the CONSTRUCTOR_PLACEHOLDER_BOUNDARY flag on the middle
    constructor blocking replace_placeholders_r from reaching it.

    To fix this, we could perhaps either call replace_placeholders in more
places,
    or we could change where we set CONSTRUCTOR_PLACEHOLDER_BOUNDARY.  This
patch
    takes this latter approach -- when building up an array initializer, we now
    bubble any CONSTRUCTOR_PLACEHOLDER_BOUNDARY flag from the element
initializers
    up to the array initializer so that the boundary doesn't later impede us
when we
    call replace_placeholders from store_init_value.

    Besides fixing the kind of code like in the testcase, this shouldn't cause
any
    other differences in PLACEHOLDER_EXPR resolution because we don't create or
use
    PLACEHOLDER_EXPRs of array type in the frontend, as far as I can tell.

    gcc/cp/ChangeLog:

            PR c++/90996
            * tree.c (replace_placeholders): Look through all handled
components,
            not just COMPONENT_REFs.
            * typeck2.c (process_init_constructor_array): Propagate
            CONSTRUCTOR_PLACEHOLDER_BOUNDARY up from each element initializer
to
            the array initializer.

    gcc/testsuite/ChangeLog:

            PR c++/90996
            * g++.dg/cpp1y/pr90996.C: New test.

Reply via email to