mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-06-04 19:00:59 +00:00
- fixed: Tacking on a return statement should only be done if the function has branches that actually reach the end. Otherwise it may interfere with return type deduction.
- used the return check to optimize out unneeded jumps at the end of an if statement's first block.
This commit is contained in:
parent
98fa3d2d93
commit
1b77a8f491
4 changed files with 65 additions and 5 deletions
|
@ -715,6 +715,13 @@ void FFunctionBuildList::Build()
|
|||
|
||||
FScriptPosition::StrictErrors = !item.FromDecorate;
|
||||
item.Code = item.Code->Resolve(ctx);
|
||||
if (!item.Code->CheckReturn())
|
||||
{
|
||||
auto newcmpd = new FxCompoundStatement(item.Code->ScriptPosition);
|
||||
newcmpd->Add(item.Code);
|
||||
newcmpd->Add(new FxReturnStatement(nullptr, item.Code->ScriptPosition));
|
||||
item.Code = newcmpd->Resolve(ctx);
|
||||
}
|
||||
item.Proto = ctx.ReturnProto;
|
||||
|
||||
// Make sure resolving it didn't obliterate it.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue