1
0
mirror of synced 2025-01-30 19:43:43 +01:00

Actually fix crash when creating zero sized arrays

If size is zero, the array will be treated as non-existent. This fixes #50
This commit is contained in:
WerWolv 2020-12-06 22:52:15 +01:00
parent 9425569784
commit 5c96a28fb6

View File

@ -69,6 +69,9 @@ namespace hex::lang {
return { nullptr, 0 };
}
if (arraySize.value() == 0)
continue;
ASTNodeVariableDecl *processedMember = new ASTNodeVariableDecl(member->getLineNumber(), member->getVariableType(), member->getVariableName(), member->getCustomVariableTypeName(), member->getOffset(), arraySize.value());
std::tie(pattern, memberSize) = this->createArrayPattern(processedMember, memberOffset);
@ -161,10 +164,8 @@ namespace hex::lang {
return { nullptr, 0 };
}
if (arraySize.value() == 0) {
this->m_error = { varDeclNode->getLineNumber(), hex::format("Value of '%s' is zero", member->getArraySizeVariable().value().c_str()) };
return { nullptr, 0 };
}
if (arraySize.value() == 0)
continue;
ASTNodeVariableDecl *processedMember = new ASTNodeVariableDecl(member->getLineNumber(), member->getVariableType(), member->getVariableName(), member->getCustomVariableTypeName(), member->getOffset(), arraySize.value());