Skip to content

Commit

Permalink
Merge pull request #5577 from 9rnsr/fix15333
Browse files Browse the repository at this point in the history
Issue 15333 - Assertion failed: (!fd->vthis->csym), function FuncDeclaration_toObjFile, file glue.c, line 1034
  • Loading branch information
WalterBright committed Mar 26, 2016
2 parents 0624da5 + 0370213 commit 403fc69
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/declaration.h
Expand Up @@ -591,6 +591,8 @@ class FuncDeclaration : public Declaration
// Sibling nested functions which called this one
FuncDeclarations siblingCallers;

FuncDeclarations *inlinedNestedCallees;

unsigned flags; // FUNCFLAGxxxxx

FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageClass storage_class, Type *type);
Expand Down
2 changes: 2 additions & 0 deletions src/func.d
Expand Up @@ -484,6 +484,8 @@ public:
// Sibling nested functions which called this one
FuncDeclarations siblingCallers;

FuncDeclarations *inlinedNestedCallees;

uint flags; // FUNCFLAGxxxxx

final extern (D) this(Loc loc, Loc endloc, Identifier id, StorageClass storage_class, Type type)
Expand Down
17 changes: 17 additions & 0 deletions src/glue.c
Expand Up @@ -881,6 +881,23 @@ void FuncDeclaration_toObjFile(FuncDeclaration *fd, bool multiobj)
if (fd->isArrayOp)
s->Sclass = SCcomdat;

if (fd->inlinedNestedCallees)
{
/* Bugzilla 15333: If fd contains inlined expressions that come from
* nested function bodies, the enclosing of the functions must be
* generated first, in order to calculate correct frame pointer offset.
*/
for (size_t i = 0; i < fd->inlinedNestedCallees->dim; i++)
{
FuncDeclaration *f = (*fd->inlinedNestedCallees)[i];
FuncDeclaration *fp = f->toParent2()->isFuncDeclaration();;
if (fp && fp->semanticRun < PASSobj)
{
toObjFile(fp, multiobj);
}
}
}

if (fd->isNested())
{
//if (!(config.flags3 & CFG3pic))
Expand Down
7 changes: 7 additions & 0 deletions src/inline.d
Expand Up @@ -2069,6 +2069,13 @@ void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration parent, Expre
}
scope ids = new InlineDoState(parent, fd);

if (fd.isNested())
{
if (!parent.inlinedNestedCallees)
parent.inlinedNestedCallees = new FuncDeclarations();
parent.inlinedNestedCallees.push(fd);
}

VarDeclaration vret; // will be set the function call result
if (eret)
{
Expand Down
14 changes: 14 additions & 0 deletions test/compilable/ice15333.d
@@ -0,0 +1,14 @@
// EXTRA_SOURCES: imports/a15333.d

module ice15333;

void map(alias fun)() {}

struct IdentifierResolver(alias handler)
{
void resolve()
{
map!((a) {});
handler(true);
}
}
12 changes: 12 additions & 0 deletions test/compilable/imports/a15333.d
@@ -0,0 +1,12 @@
module imports.a15333;

import ice15333;

struct StatementVisitor
{
void visit()
{
int location;
alias IR = IdentifierResolver!((e){ location = 0; });
}
}

0 comments on commit 403fc69

Please sign in to comment.