Skip to content

Commit

Permalink
fix Issue 15210 - [ICE] (glue.c at 1489) with tuples and AAs
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Oct 21, 2015
1 parent 1e5d3b0 commit 202d2da
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/func.d
Expand Up @@ -3783,10 +3783,9 @@ extern (C++) Expression addInvariant(Loc loc, Scope* sc, AggregateDeclaration ad
v.type = vthis.type;
if (ad.isStructDeclaration())
v = v.addressOf();
Expression se = new StringExp(Loc(), cast(char*)"null this");
se = se.semantic(sc);
se.type = Type.tchar.arrayOf();
e = new AssertExp(loc, v, se);
e = new StringExp(Loc(), cast(char*)"null this");
e = new AssertExp(loc, v, e);
e = e.semantic(sc);
}
return e;
}
Expand Down
8 changes: 8 additions & 0 deletions src/inline.d
Expand Up @@ -2144,6 +2144,14 @@ void expandInline(FuncDeclaration fd, FuncDeclaration parent, Expression eret,
e = Expression.combine(de, ve);
//fprintf(stderr, "CallExp.inlineScan: e = "); e.print();
}

// Bugzilla 15210
if (tf.next.ty == Tvoid && e && e.type.ty != Tvoid)
{
e = new CastExp(e.loc, e, Type.tvoid);
e.type = Type.tvoid;
}

eresult = e;
}
//printf("%s.expandInline = { %s }\n", fd.toChars(), e.toChars());
Expand Down
36 changes: 33 additions & 3 deletions test/runnable/inline.d
Expand Up @@ -736,20 +736,49 @@ void test14753(string) { }

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

struct S14975 {
struct S14975
{
int bar;

pragma(inline, true) this(int bar) {
pragma(inline, true) this(int bar)
{
this.bar = bar;
}
}

void test14975() {
void test14975()
{
S14975 baz = 1;
if (baz.bar != 1)
assert(0);
}

/**********************************/
// 15210

struct BigInt15210 {}

struct Tuple15210(Types...)
{
Types field;

void opAssign(R)(R rhs)
{
field = rhs.field;
}
}

void test15210()
{
alias X = Tuple15210!BigInt15210;

X[BigInt15210] cache;

auto x = X();

cache[BigInt15210()] = x;
}

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

int foo7625(int v)
Expand Down Expand Up @@ -846,6 +875,7 @@ int main()
test14754();
test14606();
test14975();
test15210();
test7625();
test9785();
test9785_2();
Expand Down

0 comments on commit 202d2da

Please sign in to comment.