Skip to content

Commit d5a33a1

Browse files
committed
fix Issue 2962 - ICE(glue.c) or bad codegen passing variable as template value parameter
1 parent 8208fcf commit d5a33a1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/glue.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,20 @@ void FuncDeclaration::toObjFile(int multiobj)
581581
// if (!(config.flags3 & CFG3pic))
582582
// s->Sclass = SCstatic;
583583
f->Fflags3 |= Fnested;
584+
585+
/* The enclosing function must have its code generated first,
586+
* so we know things like where its local symbols are stored.
587+
*/
588+
FuncDeclaration *fdp = toParent2()->isFuncDeclaration();
589+
if (fdp && fdp->semanticRun == PASSsemantic3done &&
590+
!fdp->isUnitTestDeclaration())
591+
{
592+
/* Can't do unittest's out of order, they are order dependent in that their
593+
* execution is done in lexical order, and some modules (std.datetime *cough*
594+
* *cough*) rely on this.
595+
*/
596+
fdp->toObjFile(multiobj);
597+
}
584598
}
585599
else
586600
{

0 commit comments

Comments
 (0)