Skip to content

Commit

Permalink
[semantic3.d] use early continue
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilsonator committed Oct 21, 2024
1 parent 7457513 commit be97f4d
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions compiler/src/dmd/semantic3.d
Original file line number Diff line number Diff line change
Expand Up @@ -1175,32 +1175,31 @@ private extern(C++) final class Semantic3Visitor : Visitor
{
if (v.isReference() || (v.storage_class & STC.lazy_))
continue;
if (v.needsScopeDtor())
{
v.storage_class |= STC.nodtor;
if (!paramsNeedDtor)
continue;

// same with ExpStatement.scopeCode()
Statement s = new DtorExpStatement(Loc.initial, v.edtor, v);
if (!v.needsScopeDtor())
continue;
v.storage_class |= STC.nodtor;
if (!paramsNeedDtor)
continue;

s = s.statementSemantic(sc2);
// same with ExpStatement.scopeCode()
Statement s = new DtorExpStatement(Loc.initial, v.edtor, v);

const blockexit = s.blockExit(funcdecl, isNothrow ? global.errorSink : null);
if (blockexit & BE.throw_)
{
funcdecl.hasNoEH = false;
if (isNothrow)
error(funcdecl.loc, "%s `%s` may throw but is marked as `nothrow`", funcdecl.kind(), funcdecl.toPrettyChars());
else if (funcdecl.nothrowInprocess)
f.isNothrow = false;
}
s = s.statementSemantic(sc2);

if (sbody.blockExit(funcdecl, f.isNothrow ? global.errorSink : null) == BE.fallthru)
sbody = new CompoundStatement(Loc.initial, sbody, s);
else
sbody = new TryFinallyStatement(Loc.initial, sbody, s);
const blockexit = s.blockExit(funcdecl, isNothrow ? global.errorSink : null);
if (blockexit & BE.throw_)
{
funcdecl.hasNoEH = false;
if (isNothrow)
error(funcdecl.loc, "%s `%s` may throw but is marked as `nothrow`", funcdecl.kind(), funcdecl.toPrettyChars());
else if (funcdecl.nothrowInprocess)
f.isNothrow = false;
}

if (sbody.blockExit(funcdecl, f.isNothrow ? global.errorSink : null) == BE.fallthru)
sbody = new CompoundStatement(Loc.initial, sbody, s);
else
sbody = new TryFinallyStatement(Loc.initial, sbody, s);
}
}
// from this point on all possible 'throwers' are checked
Expand Down

0 comments on commit be97f4d

Please sign in to comment.