mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-29 07:22:07 +00:00
Compile time check for abstract class instantiation to reduce programming errors ASAP
This commit is contained in:
parent
0819dd8d89
commit
0803faf596
1 changed files with 7 additions and 0 deletions
|
@ -5058,6 +5058,13 @@ FxExpression *FxNew::Resolve(FCompileContext &ctx)
|
|||
if (val->isConstant())
|
||||
{
|
||||
auto cls = static_cast<PClass *>(static_cast<FxConstant*>(val)->GetValue().GetPointer());
|
||||
if ((cls->ObjectFlags & OF_Abstract) && cls != ctx.Class)
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Cannot instantiate abstract class %s outside of that class", cls->TypeName.GetChars());
|
||||
delete this;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ValueType = NewPointer(cls);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue