- fixed: an 'if' that gets completely optimized away by a constant 'false' condition should not make the entire function disappear.

This commit is contained in:
Christoph Oelckers 2016-04-07 20:31:12 +02:00
parent 0cbdb9ab72
commit 58002f7f96
2 changed files with 20 additions and 0 deletions

View File

@ -997,6 +997,25 @@ public:
void SetFunction(VMScriptFunction *func) { MyFunction = func; }
};
//==========================================================================
//
//
//
//==========================================================================
class FxNop : public FxExpression
{
public:
FxNop(const FScriptPosition &p)
: FxExpression(p)
{
isresolved = true;
}
ExpEmit Emit(VMFunctionBuilder *build)
{
return ExpEmit();
}
};
FxExpression *ParseExpression (FScanner &sc, PClassActor *cls, bool mustresolve = false);

View File

@ -3648,6 +3648,7 @@ FxExpression *FxIfStatement::Resolve(FCompileContext &ctx)
FxExpression *e = result ? WhenTrue : WhenFalse;
delete (result ? WhenFalse : WhenTrue);
WhenTrue = WhenFalse = NULL;
if (e == NULL) e = new FxNop(ScriptPosition); // create a dummy if this statement gets completely removed by optimizing out the constant parts.
delete this;
return e;
}