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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Iain Buclaw
<ibuc...@gcc.gnu.org>:

https://gcc.gnu.org/g:ec3a01024dd86c51d1e563df9395123765cf548d

commit r12-10202-gec3a01024dd86c51d1e563df9395123765cf548d
Author: Iain Buclaw <ibuc...@gdcproject.org>
Date:   Sun Mar 10 17:49:06 2024 +0100

    d: Fix -fpreview=in ICEs with forward referenced parameter [PR112285]

    The way that the target hook preferPassByRef is implemented, it relied
    on the GCC "back-end" tree type to determine whether or not to use `ref'
    ABI for D `in' parameters; e.g: prefer by value if it is expected that
    the target will pass the type around in registers.

    Building the GCC tree type depends on the AST type being complete - all
    semantic processing is finished - but as this hook is called from the
    front-end, this will not be the case for forward referenced or
    self-referencing types.

    The consensus in upstream is that `in' parameters should always be
    implicitly `ref', but as the front-end does not yet support all types
    being rvalue references, limit this just static arrays and structs.

            PR d/112285
            PR d/112290

    gcc/d/ChangeLog:

            * d-target.cc (Target::preferPassByRef): Return true for all static
            array and struct types.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr112285.d: New test.
            * gdc.dg/pr112290.d: New test.
            * gdc.test/compilable/previewin.d: Adjust testcase.

    (cherry picked from commit 025ff57c19efae6c8d76df6b93e7d9827017acc9)

Reply via email to