Skip to content

Commit dfd2aa5

Browse files
committed
Merge fix: Revert to needsClosure() in gen/nested.cpp
As `FuncDeclaration.requiresClosure` appears not to be computed in all cases yet - this fixes a std.algorithm.iteration unittest regression.
1 parent 68320a0 commit dfd2aa5

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

dmd/cxxfrontend.d

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,12 @@ PURE isPure(FuncDeclaration fd)
439439
return dmd.funcsem.isPure(fd);
440440
}
441441

442+
bool needsClosure(FuncDeclaration fd)
443+
{
444+
import dmd.funcsem;
445+
return dmd.funcsem.needsClosure(fd);
446+
}
447+
442448
/***********************************************************
443449
* hdrgen.d
444450
*/

dmd/declaration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace dmd
3737
bool checkClosure(FuncDeclaration* fd);
3838
MATCH leastAsSpecialized(FuncDeclaration *f, FuncDeclaration *g, ArgumentLabels *names);
3939
PURE isPure(FuncDeclaration *f);
40+
bool needsClosure(FuncDeclaration *fd);
4041
FuncDeclaration *genCfunc(Parameters *args, Type *treturn, const char *name, StorageClass stc=0);
4142
FuncDeclaration *genCfunc(Parameters *args, Type *treturn, Identifier *id, StorageClass stc=0);
4243
bool isAbstract(ClassDeclaration *cd);

gen/nested.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ unsigned getVthisIdx(AggregateDeclaration *ad) {
3232

3333
bool isNRVOVar(VarDeclaration *vd) {
3434
if (auto fd = vd->toParent2()->isFuncDeclaration())
35-
return fd->isNRVO() && vd == fd->nrvo_var && !fd->requiresClosure;
35+
return fd->isNRVO() && vd == fd->nrvo_var && !dmd::needsClosure(fd);
3636
return false;
3737
}
3838

@@ -487,7 +487,7 @@ void DtoCreateNestedContext(FuncGenState &funcGen) {
487487

488488
// Create frame for current function and append to frames list
489489
LLValue *frame = nullptr;
490-
bool needsClosure = fd->requiresClosure;
490+
bool needsClosure = dmd::needsClosure(fd);
491491
IF_LOG Logger::println("Needs closure (GC) flag: %d", (int)needsClosure);
492492
if (needsClosure) {
493493
LLFunction *fn =

0 commit comments

Comments
 (0)