Skip to content

Commit

Permalink
Issue 7261 - ICE(glue.c): With taskPool.reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Feb 6, 2012
1 parent 9c38305 commit 05e6f16
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/inline.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ int lambdaInlineCost(Expression *e, void *param)
int expressionInlineCost(Expression *e, InlineCostState *ics)
{
//printf("expressionInlineCost()\n");
//e->dump(0);
ICS2 ics2;
ics2.cost = 0;
ics2.ics = ics;
Expand Down Expand Up @@ -223,7 +224,7 @@ int VarExp::inlineCost3(InlineCostState *ics)
return COST_MAX;
}
FuncDeclaration *fd = var->isFuncDeclaration();
if (fd && fd->isNested())
if (fd && fd->isNested()) // see Bugzilla 7199 for test case
return COST_MAX;
return 1;
}
Expand Down Expand Up @@ -349,6 +350,7 @@ struct InlineDoState
Dsymbols from; // old Dsymbols
Dsymbols to; // parallel array of new Dsymbols
Dsymbol *parent; // new parent
FuncDeclaration *fd; // function being inlined (old parent)
};

/* -------------------------------------------------------------------- */
Expand Down Expand Up @@ -644,6 +646,12 @@ Expression *VarExp::doInline(InlineDoState *ids)
return ve;
}
}
if (ids->fd && var == ids->fd->vthis)
{ VarExp *ve = new VarExp(loc, ids->vthis);
ve->type = type;
return ve;
}

return this;
}

Expand Down Expand Up @@ -1586,6 +1594,7 @@ Expression *FuncDeclaration::expandInline(InlineScanState *iss, Expression *ethi

memset(&ids, 0, sizeof(ids));
ids.parent = iss->fd;
ids.fd = this;

if (ps)
as = new Statements();
Expand Down
43 changes: 43 additions & 0 deletions test/runnable/inline.d
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,48 @@ void test7()
auto x = foo7('c');
}

/************************************/
// Bugzilla 4825

int a8() {
int r;
return r;
}

int b8() {
return a8();
}

void test8() {
void d() {
auto e = b8();
}
static const int f = b8();
}

/************************************/
// 7261

struct AbstractTask
{
ubyte taskStatus;
}

struct Task
{
AbstractTask base;
alias base this;

void opAssign(Task rhs)
{
}

~this()
{
if (taskStatus != 3) { }
}
}

/************************************/

int main()
Expand All @@ -152,6 +194,7 @@ int main()
test5();
test6();
test7();
test8();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 05e6f16

Please sign in to comment.