Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge upstream stable (dlang/dmd@9337377c8a) #3796

Merged
merged 1 commit into from
Jul 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dmd/escape.d
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ ByRef:
* then uncount that address of. This is so it won't cause a
* closure to be allocated.
*/
if (va && va.isScope() && fd.tookAddressOf)
if (va && va.isScope() && !(va.storage_class & STC.return_) && fd.tookAddressOf)
--fd.tookAddressOf;

foreach (v; vars)
Expand Down
4 changes: 2 additions & 2 deletions dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,7 @@ private bool functionParameters(const ref Loc loc, Scope* sc,
if (global.params.vsafe)
err |= checkParamArgumentEscape(sc, fd, p, arg, false, false);
}
else
else if (!(p.storageClass & STC.return_))
{
/* Argument value cannot escape from the called function.
*/
Expand All @@ -2077,7 +2077,7 @@ private bool functionParameters(const ref Loc loc, Scope* sc,
a = (cast(CastExp)a).e1;

ArrayLiteralExp ale;
if (p.type.toBasetype().ty == Tarray && !(p.storageClass & STC.return_) &&
if (p.type.toBasetype().ty == Tarray &&
(ale = a.isArrayLiteralExp()) !is null)
{
// allocate the array literal as temporary static array on the stack
Expand Down
2 changes: 1 addition & 1 deletion tests/d2/dmd-testsuite