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:
parent
9425569784
commit
5c96a28fb6
@ -69,6 +69,9 @@ namespace hex::lang {
|
|||||||
return { nullptr, 0 };
|
return { nullptr, 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arraySize.value() == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
ASTNodeVariableDecl *processedMember = new ASTNodeVariableDecl(member->getLineNumber(), member->getVariableType(), member->getVariableName(), member->getCustomVariableTypeName(), member->getOffset(), arraySize.value());
|
ASTNodeVariableDecl *processedMember = new ASTNodeVariableDecl(member->getLineNumber(), member->getVariableType(), member->getVariableName(), member->getCustomVariableTypeName(), member->getOffset(), arraySize.value());
|
||||||
|
|
||||||
std::tie(pattern, memberSize) = this->createArrayPattern(processedMember, memberOffset);
|
std::tie(pattern, memberSize) = this->createArrayPattern(processedMember, memberOffset);
|
||||||
@ -161,10 +164,8 @@ namespace hex::lang {
|
|||||||
return { nullptr, 0 };
|
return { nullptr, 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arraySize.value() == 0) {
|
if (arraySize.value() == 0)
|
||||||
this->m_error = { varDeclNode->getLineNumber(), hex::format("Value of '%s' is zero", member->getArraySizeVariable().value().c_str()) };
|
continue;
|
||||||
return { nullptr, 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
ASTNodeVariableDecl *processedMember = new ASTNodeVariableDecl(member->getLineNumber(), member->getVariableType(), member->getVariableName(), member->getCustomVariableTypeName(), member->getOffset(), arraySize.value());
|
ASTNodeVariableDecl *processedMember = new ASTNodeVariableDecl(member->getLineNumber(), member->getVariableType(), member->getVariableName(), member->getCustomVariableTypeName(), member->getOffset(), arraySize.value());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user