mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-15 08:41:59 +00:00
- fixed: Type determination of multi-dimensional arrays failed, apparently because ZCCCompiler::Simplify is too broken to leave the node's ring list intact.
Instead of trying to fix Simplify, which seems to be a lost cause, the ring list now gets unraveled into an array which is immune from this type of problem.
This commit is contained in:
parent
b17bd65279
commit
902a4b839c
1 changed files with 12 additions and 6 deletions
|
@ -1583,12 +1583,19 @@ PType *ZCCCompiler::ResolveUserType(ZCC_BasicType *type, PSymbolTable *symt)
|
|||
|
||||
PType *ZCCCompiler::ResolveArraySize(PType *baseType, ZCC_Expression *arraysize, PSymbolTable *sym)
|
||||
{
|
||||
// The duplicate Simplify call is necessary because if the head node gets replaced there is no way to detect the end of the list otherwise.
|
||||
arraysize = Simplify(arraysize, sym, true);
|
||||
ZCC_Expression *val;
|
||||
TArray<ZCC_Expression *> indices;
|
||||
|
||||
// Simplify is too broken to resolve this inside the ring list so unravel the list into an array before starting to simplify its components.
|
||||
auto node = arraysize;
|
||||
do
|
||||
{
|
||||
val = Simplify(arraysize, sym, true);
|
||||
indices.Push(node);
|
||||
node = static_cast<ZCC_Expression*>(node->SiblingNext);
|
||||
} while (node != arraysize);
|
||||
|
||||
for (auto node : indices)
|
||||
{
|
||||
auto val = Simplify(node, sym, true);
|
||||
if (val->Operation != PEX_ConstValue || !val->Type->IsA(RUNTIME_CLASS(PInt)))
|
||||
{
|
||||
Error(arraysize, "Array index must be an integer constant");
|
||||
|
@ -1601,8 +1608,7 @@ PType *ZCCCompiler::ResolveArraySize(PType *baseType, ZCC_Expression *arraysize,
|
|||
return TypeError;
|
||||
}
|
||||
baseType = NewArray(baseType, size);
|
||||
val = static_cast<ZCC_Expression *>(val->SiblingNext);
|
||||
} while (val != arraysize);
|
||||
}
|
||||
return baseType;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue