Showing with 44 additions and 7 deletions.
  1. +3 −4 src/func.d
  2. +8 −0 src/inline.d
  3. +33 −3 test/runnable/inline.d
7 changes: 3 additions & 4 deletions src/func.d
Original file line number Diff line number Diff line change
Expand Up @@ -3779,10 +3779,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
Original file line number Diff line number Diff line change
Expand Up @@ -2180,6 +2180,14 @@ void expandInline(FuncDeclaration fd, FuncDeclaration parent, Expression eret,

//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] %s expandInline = { %s }\n", fd.loc.toChars(), fd.toPrettyChars(), e.toChars());
Expand Down
36 changes: 33 additions & 3 deletions test/runnable/inline.d
Original file line number Diff line number Diff line change
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 @@ -890,6 +919,7 @@ int main()
test14754();
test14606();
test14975();
test15210();
test7625();
test9785();
test9785_2();
Expand Down