Showing with 54 additions and 4 deletions.
  1. +3 −3 src/dinterpret.d
  2. +14 −1 src/inline.d
  3. +14 −0 test/compilable/interpret3.d
  4. +23 −0 test/runnable/inline.d
6 changes: 3 additions & 3 deletions src/dinterpret.d
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ public:
result = e; // bubbled up from ReturnStatement
return;
}
e = interpret(s.increment, istate); // TODO: ctfeNeedNothing is better?
e = interpret(s.increment, istate, ctfeNeedNothing);
if (exceptionOrCant(e))
return;
}
Expand Down Expand Up @@ -5459,9 +5459,9 @@ public:
if (exceptionOrCant(e1))
return;
// If the expression has been cast to void, do nothing.
if (e.to.ty == Tvoid && goal == ctfeNeedNothing)
if (e.to.ty == Tvoid)
{
result = e1;
result = CTFEExp.voidexp;
return;
}
if (e.to.ty == Tpointer && e1.op != TOKnull)
Expand Down
15 changes: 14 additions & 1 deletion src/inline.d
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,20 @@ void expandInline(FuncDeclaration fd, FuncDeclaration parent, Expression eret,
if (vfrom.type.ty == Tdelegate ||
vfrom.type.ty == Tpointer && vfrom.type.nextOf().ty == Tfunction)
{
again = true;
if (arg.op == TOKvar)
{
VarExp ve = cast(VarExp)arg;
if (ve.var.isFuncDeclaration())
again = true;
}
else if (arg.op == TOKsymoff)
{
SymOffExp se = cast(SymOffExp)arg;
if (se.var.isFuncDeclaration())
again = true;
}
else if (arg.op == TOKfunction || arg.op == TOKdelegate)
again = true;
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions test/compilable/interpret3.d
Original file line number Diff line number Diff line change
Expand Up @@ -7664,3 +7664,17 @@ struct Tok15233 {}
enum tup15233 = TT15233!(Tok15233(), "foo");
static assert(tup15233[0] == Tok15233());
static assert(tup15233[1] == "foo");

/**************************************************
15251 - void cast in ForStatement.increment
**************************************************/

int test15251()
{
for (ubyte lwr = 19;
lwr != 20;
cast(void)++lwr) // have to to be evaluated with ctfeNeedNothing
{}
return 1;
}
static assert(test15251());
23 changes: 23 additions & 0 deletions test/runnable/inline.d
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,29 @@ void test15207()
auto c = new C15207();
}

/**********************************/
// 15253

struct MessageType15253
{
MessageType15253[] messageTypes;

const void toString1(scope void delegate(const(char)[]) sink)
{
messageTypes[0].toString1(sink);
}
}

struct ProtoPackage15253
{
MessageType15253[] messageTypes;

const void toString1(scope void delegate(const(char)[]) sink)
{
messageTypes[0].toString1(sink);
}
}

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

int main()
Expand Down