Fixed nested structs breaking the ZScript compiler under certain circumstances.

This commit is contained in:
Chronos Ouroboros 2020-08-15 10:35:21 -03:00 committed by drfrag
parent 2c3303e723
commit 0ea4e182c7
2 changed files with 16 additions and 1 deletions

View file

@ -100,6 +100,7 @@ public:
VersionInfo mVersion = { 0,0,0 };
uint8_t loadOp, storeOp, moveOp, RegType, RegCount;
EScopeFlags ScopeFlags = (EScopeFlags)0;
bool SizeKnown = true;
PType(unsigned int size = 1, unsigned int align = 1);
virtual ~PType();

View file

@ -1492,8 +1492,12 @@ bool ZCCCompiler::CompileFields(PContainerType *type, TArray<ZCC_VarDeclarator *
auto name = field->Names;
do
{
if (fieldtype->Size == 0 && !(varflags & VARF_Native)) // Size not known yet.
if ((fieldtype->Size == 0 || !fieldtype->SizeKnown) && !(varflags & VARF_Native)) // Size not known yet.
{
if (type != nullptr)
{
type->SizeKnown = false;
}
return false;
}
@ -1548,6 +1552,10 @@ bool ZCCCompiler::CompileFields(PContainerType *type, TArray<ZCC_VarDeclarator *
if (OutNamespace->Symbols.AddSymbol(f) == nullptr)
{ // name is already in use
if (type != nullptr)
{
type->SizeKnown = false;
}
f->Destroy();
return false;
}
@ -1577,6 +1585,12 @@ bool ZCCCompiler::CompileFields(PContainerType *type, TArray<ZCC_VarDeclarator *
} while (name != field->Names);
Fields.Delete(0);
}
if (type != nullptr)
{
type->SizeKnown = Fields.Size() == 0;
}
return Fields.Size() == 0;
}