Skip to content

Commit

Permalink
Merge pull request #5192 from 9rnsr/fix15200
Browse files Browse the repository at this point in the history
[REG2.068.2] Issue 15200 - ICE(glue.c) when compiling with -inline
  • Loading branch information
WalterBright committed Oct 13, 2015
2 parents d752f69 + 204df57 commit 1e5d3b0
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/dtemplate.d
Original file line number Diff line number Diff line change
Expand Up @@ -7346,8 +7346,8 @@ public:
}
//printf("%s->appendToModuleMember() enclosing = %s mi = %s\n",
// toPrettyChars(),
// enclosing ? enclosing.toPrettyChars() : NULL,
// mi ? mi.toPrettyChars() : NULL);
// enclosing ? enclosing.toPrettyChars() : null,
// mi ? mi.toPrettyChars() : null);
if (!mi || mi.isRoot())
{
/* If the instantiated module is speculative or root, insert to the
Expand Down
8 changes: 0 additions & 8 deletions src/inline.d
Original file line number Diff line number Diff line change
Expand Up @@ -1948,14 +1948,6 @@ void expandInline(FuncDeclaration fd, FuncDeclaration parent, Expression eret,
}
scope ids = new InlineDoState(parent, fd);

// When the function is actually expanded
if (TemplateInstance ti = fd.isInstantiated())
{
// change ti to non-speculative root instance
if (!ti.minst)
ti.minst = ti.tempdecl.getModule().importedFrom;
}

if (asStatements)
as = new Statements();
VarDeclaration vret = null;
Expand Down
11 changes: 11 additions & 0 deletions test/runnable/ice15200.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// EXTRA_SOURCES: imports/ice15200a.d imports/ice15200b.d
// COMPILE_SEPARATELY

module ice15200;

import imports.ice15200a;

void main()
{
f();
}
12 changes: 12 additions & 0 deletions test/runnable/imports/ice15200a.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import imports.ice15200b;

auto f() // not void
{
sub([0], false);
}
void sub(R)(R list, bool b)
{
foreach (i; list.filter!(delegate(e) => b))
{
}
}
41 changes: 41 additions & 0 deletions test/runnable/imports/ice15200b.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module imports.ice15200b;

template filter(alias pred)
{
auto filter(R)(R range)
{
return FilterResult!(pred, R)(range);
}
}

struct FilterResult(alias pred, R)
{
R _input;

this(R r)
{
_input = r;
while (_input.length && !pred(_input[0]))
{
_input = _input[1..$];
}
}

@property bool empty()
{
return _input.length == 0;
}

@property auto ref front()
{
return _input[0];
}

void popFront()
{
do
{
_input = _input[1..$];
} while (_input.length && !pred(_input[0]));
}
}

0 comments on commit 1e5d3b0

Please sign in to comment.