mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 16:07:55 +00:00
- fixed: The CheckReturn check for FxSwitchStatement was not strict enough.
It may only return true if there is no default case because without that any non-matching value will go past the statement.
This commit is contained in:
parent
e13627e9d8
commit
b74c374a66
1 changed files with 7 additions and 2 deletions
|
@ -8926,15 +8926,20 @@ ExpEmit FxSwitchStatement::Emit(VMFunctionBuilder *build)
|
||||||
|
|
||||||
bool FxSwitchStatement::CheckReturn()
|
bool FxSwitchStatement::CheckReturn()
|
||||||
{
|
{
|
||||||
//A switch statement returns when it contains no breaks and ends with a return
|
bool founddefault = false;
|
||||||
|
//A switch statement returns when it contains a no breaks, a default case, and ends with a return
|
||||||
for (auto line : Content)
|
for (auto line : Content)
|
||||||
{
|
{
|
||||||
if (line->ExprType == EFX_JumpStatement)
|
if (line->ExprType == EFX_JumpStatement)
|
||||||
{
|
{
|
||||||
return false; // Break means that the end of the statement will be reached, Continue cannot happen in the last statement of the last block.
|
return false; // Break means that the end of the statement will be reached, Continue cannot happen in the last statement of the last block.
|
||||||
}
|
}
|
||||||
|
else if (line->ExprType == EFX_CaseStatement)
|
||||||
|
{
|
||||||
|
if (static_cast<FxCaseStatement*>(line)->Condition == nullptr) founddefault = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Content.Size() > 0 && Content.Last()->CheckReturn();
|
return founddefault && Content.Size() > 0 && Content.Last()->CheckReturn();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
Loading…
Reference in a new issue