mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Fixed cases where param modification of sized arrays should be an error
This commit is contained in:
parent
4d29ecfd31
commit
4afc8eb3dc
2 changed files with 13 additions and 2 deletions
|
@ -3052,7 +3052,7 @@ void BfExprEvaluator::Visit(BfLiteralExpression* literalExpr)
|
|||
|
||||
BfTypedValue BfExprEvaluator::LoadLocal(BfLocalVariable* varDecl, bool allowRef)
|
||||
{
|
||||
if (!mModule->mIsInsideAutoComplete)
|
||||
if (!mModule->mIsInsideAutoComplete)
|
||||
varDecl->mReadFromId = mModule->mCurMethodState->GetRootMethodState()->mCurAccessId++;
|
||||
|
||||
// The Beef backend prefers readonly addrs since that reduces register pressure, whereas
|
||||
|
@ -3139,7 +3139,7 @@ BfTypedValue BfExprEvaluator::LoadLocal(BfLocalVariable* varDecl, bool allowRef)
|
|||
else if (varDecl->mHasLocalStructBacking)
|
||||
{
|
||||
// varDecl->mAddr is a "struct**"
|
||||
localResult = BfTypedValue(mModule->mBfIRBuilder->CreateAlignedLoad(varDecl->mAddr, varDecl->mResolvedType->mAlign), varDecl->mResolvedType, true);
|
||||
localResult = BfTypedValue(mModule->mBfIRBuilder->CreateAlignedLoad(varDecl->mAddr, varDecl->mResolvedType->mAlign), varDecl->mResolvedType, varDecl->mIsReadOnly ? BfTypedValueKind_ReadOnlyAddr : BfTypedValueKind_Addr);
|
||||
}
|
||||
else
|
||||
localResult = BfTypedValue(varDecl->mAddr, varDecl->mResolvedType, varDecl->mIsReadOnly ? BfTypedValueKind_ReadOnlyAddr : BfTypedValueKind_Addr);
|
||||
|
@ -15241,6 +15241,11 @@ bool BfExprEvaluator::CheckIsBase(BfAstNode* checkNode)
|
|||
|
||||
bool BfExprEvaluator::CheckModifyResult(BfTypedValue typedVal, BfAstNode* refNode, const char* modifyType, bool onlyNeedsMut)
|
||||
{
|
||||
if (mModule->mCurMethodInstance->mIdHash == 0x1C000003A3)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
BfLocalVariable* localVar = NULL;
|
||||
bool isCapturedLocal = false;
|
||||
if (mResultLocalVar != NULL)
|
||||
|
|
|
@ -1108,6 +1108,12 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
|
|||
arrayType->mSize = (arrayType->mElementType->GetStride() * ((int)arrayType->mElementCount - 1)) + arrayType->mElementType->mSize;
|
||||
arrayType->mAlign = std::max((int32)arrayType->mElementType->mAlign, 1);
|
||||
}
|
||||
else if (arrayType->mElementCount < 0)
|
||||
{
|
||||
// Unknown size, don't assume it's valueless
|
||||
arrayType->mSize = 1;
|
||||
arrayType->mAlign = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
arrayType->mSize = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue