Skip to content

Commit

Permalink
another case for Issue 9875
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Oct 1, 2015
1 parent ae47818 commit 4eec962
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/inline.d
Expand Up @@ -1493,7 +1493,7 @@ public:
*/
void visitCallExp(CallExp e, Expression eret, bool asStatements)
{
//printf("CallExp.inlineScan()\n");
//printf("CallExp.inlineScan() %s\n", e.toChars());
FuncDeclaration fd;
if (e.e1.op == TOKvar)
{
Expand Down Expand Up @@ -1539,7 +1539,16 @@ public:
if (ei && ei.exp.op == TOKblit)
{
Expression e2 = (cast(AssignExp)ei.exp).e2;
if (e2.op == TOKfunction)
if (e2.op == TOKsymoff)
{
auto se = cast(SymOffExp)e2;
fd = se.var.isFuncDeclaration();
if (fd && fd != parent && canInline(fd, false, false, asStatements))
{
expandInline(fd, parent, eret, null, e.arguments, asStatements, eresult, sresult, again);
}
}
else if (e2.op == TOKfunction)
{
auto fld = (cast(FuncExp)e2).fd;
assert(fld.tok == TOKfunction);
Expand Down
21 changes: 21 additions & 0 deletions test/runnable/inline.d
Expand Up @@ -799,6 +799,26 @@ void test9785()
}


/**********************************/
// 9785 partial fix

void test9785_2() {
int j = 3;

void loop(scope const void function(int x) dg) {
pragma(inline, true);
dg(++j);
}

static void func(int x) {
pragma(inline, true);
printf("%d\n", x);
assert(x == 4);
}

loop(&func);
}

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

int main()
Expand Down Expand Up @@ -828,6 +848,7 @@ int main()
test14975();
test7625();
test9785();
test9785_2();

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

0 comments on commit 4eec962

Please sign in to comment.