[Issue 15166] [REG2.069-devel] spurious statement not reachable warning in static foreach loop
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Oct 12 15:47:07 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=15166
--- Comment #3 from Martin Nowak <code at dawg.eu> ---
I think something along this line could work.
override void visit(ConditionalStatement s)
{
if (s.condition.include(null, null))
{
result = s.ifbody.blockExit(func, mustNotThrow);
// mark as conditional fallthru, see Bugzilla 14835
if (!s.elsebody) result |= BEconditional;
}
else if (s.elsebody)
result = s.elsebody.blockExit(func, mustNotThrow);
else
result = BEfallthru;
}
if (!(result & (BEfallthru | BEconditional)) && !s.comeFrom())
{
if (s.blockExit(func, mustNotThrow) != BEhalt && s.hasCode())
s.warning("statement is not reachable");
}
But for this to work ConditionalStatement must no longer be flattened before
computing blockExit, thus making this change very big (and somewhat risky).
--
More information about the Digitalmars-d-bugs
mailing list