]> git.ipfire.org Git - thirdparty/gcc.git/commit
d: Fix regression returning from function with invariants [PR119139]
authorIain Buclaw <ibuclaw@gdcproject.org>
Tue, 11 Mar 2025 16:56:18 +0000 (17:56 +0100)
committerIain Buclaw <ibuclaw@gdcproject.org>
Tue, 11 Mar 2025 19:22:47 +0000 (20:22 +0100)
commitaf69315f84778dc1455d2a06d355a67ad8b9241e
tree503fbcb092f81cbeb6debf86c10f3195a1ebb802
parent79366d9bec48d90d47b463e74c6096d14b055e32
d: Fix regression returning from function with invariants [PR119139]

An optimization was added in GDC-12 which sets the TREE_READONLY flag on
all local variables with the storage class `const' assigned.  For some
reason, const is also being added by the front-end to `__result'
variables in non-virtual functions, which ends up getting wrong code by
the gimplify pass promoting the local to static storage.

A bug has been raised upstream, as this looks like an error in the AST.
For now, turn off setting TREE_READONLY on all result variables.

PR d/119139

gcc/d/ChangeLog:

* decl.cc (get_symbol_decl): Don't set TREE_READONLY for __result
declarations.

gcc/testsuite/ChangeLog:

* gdc.dg/pr119139.d: New test.

(cherry picked from commit 81582ca6cb692098c1bda7995aec46c6cbfbfcb3)
gcc/d/decl.cc
gcc/testsuite/gdc.dg/pr119139.d [new file with mode: 0644]