- fixed: A preincrement of a local variable generated wrong code if passed as a function parameter.

Due to the special nature of this expression the code generator got stuck in 'address' mode and passed the address of the variable instead of its value.
This commit is contained in:
Christoph Oelckers 2018-03-01 15:00:18 +01:00
parent 685e5c1e95
commit bcc8972356

View file

@ -2304,6 +2304,7 @@ ExpEmit FxPreIncrDecr::Emit(VMFunctionBuilder *build)
}
pointer.Free(build);
value.Target = false; // This is for 'unrequesting' the address of a register variable. If not done here, passing a preincrement expression to a function will generate bad code.
return value;
}
@ -7406,7 +7407,16 @@ ExpEmit FxArrayElement::Emit(VMFunctionBuilder *build)
if (arrayispointer)
{
arraytype = static_cast<PArray*>(Array->ValueType->toPointer()->PointedType);
auto ptr = Array->ValueType->toPointer();
if (ptr != nullptr)
{
arraytype = static_cast<PArray*>(ptr->PointedType);
}
else
{
ScriptPosition.Message(MSG_ERROR, "Internal error when generating code for array access");
return ExpEmit();
}
}
else
{