- added warning for constant conditional expression

ZScript code like `if (x = 0) // ...` no longer causes assertion failure in Debug but produces a warning regadless of configuration

https://forum.zdoom.org/viewtopic.php?t=62422
This commit is contained in:
alexey.lysiuk 2018-11-01 16:05:27 +02:00
parent d99aeb0895
commit 8597c9e326

View file

@ -382,7 +382,11 @@ void FxExpression::EmitCompare(VMFunctionBuilder *build, bool invert, TArray<siz
{ {
ExpEmit op = Emit(build); ExpEmit op = Emit(build);
ExpEmit i; ExpEmit i;
assert(op.RegType != REGT_NIL && op.RegCount == 1 && !op.Konst); assert(op.RegType != REGT_NIL && op.RegCount == 1);
if (op.Konst)
{
ScriptPosition.Message(MSG_WARNING, "Conditional expression is constant");
}
switch (op.RegType) switch (op.RegType)
{ {
case REGT_INT: case REGT_INT: