]> 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:28:49 +0000 (20:28 +0100)
commit8d8eb5327f44472e8769807a6e632e2e0d445bb9
treedad7b84180bd21371765d05626a3e2bf1982450e
parent587b370c8492aadaab14c57e242c66778cc78891
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]