mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +02:00
Added warning for arithmetic on a pointer to a sized array
This commit is contained in:
parent
c769508f0d
commit
39f7c01da3
1 changed files with 4 additions and 0 deletions
|
@ -23531,6 +23531,10 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
|
||||||
}
|
}
|
||||||
|
|
||||||
auto underlyingType = resultType->GetUnderlyingType();
|
auto underlyingType = resultType->GetUnderlyingType();
|
||||||
|
|
||||||
|
if ((underlyingType->IsSizedArray()) && (!mModule->IsInSpecializedSection()))
|
||||||
|
mModule->Warn(0, "Performing arithmetic on a pointer to a sized array. Consider performing arithmetic on an element pointer if this is not intended.", resultTypeSrc);
|
||||||
|
|
||||||
BfIRValue addValue = otherTypedValue->mValue;
|
BfIRValue addValue = otherTypedValue->mValue;
|
||||||
if ((!otherTypedValue->mType->IsSigned()) && (otherTypedValue->mType->mSize < mModule->mSystem->mPtrSize))
|
if ((!otherTypedValue->mType->IsSigned()) && (otherTypedValue->mType->mSize < mModule->mSystem->mPtrSize))
|
||||||
addValue = mModule->mBfIRBuilder->CreateNumericCast(addValue, false, BfTypeCode_UIntPtr);
|
addValue = mModule->mBfIRBuilder->CreateNumericCast(addValue, false, BfTypeCode_UIntPtr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue