From 948e50e458368c4ca063a22e685fb0fe15fb589c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Aug 2017 12:31:47 +0200 Subject: [PATCH] - fixed: The struct field compiler did not check for forward declared type references that hadn't been resolved yet. --- src/scripting/types.cpp | 1 + src/scripting/zscript/zcc_compile.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/scripting/types.cpp b/src/scripting/types.cpp index f07356d42..91ceb9077 100644 --- a/src/scripting/types.cpp +++ b/src/scripting/types.cpp @@ -2247,6 +2247,7 @@ bool PStruct::ReadValue(FSerializer &ar, const char *key, void *addr) const PField *PStruct::AddField(FName name, PType *type, uint32_t flags) { + assert(type->Size > 0); return Symbols.AddField(name, type, flags, Size, &Align); } diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 5d42d64ba..71f8e6d35 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -1298,6 +1298,11 @@ bool ZCCCompiler::CompileFields(PContainerType *type, TArrayNames; do { + if (fieldtype->Size == 0 && !(varflags & VARF_Native)) // Size not known yet. + { + return false; + } + if (AddTreeNode(name->Name, name, TreeNodes, !forstruct)) { auto thisfieldtype = fieldtype;