1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Added warning for arithmetic on a pointer to a sized array

This commit is contained in:
Brian Fiete 2022-06-06 08:24:01 -07:00
parent c769508f0d
commit 39f7c01da3

View file

@ -23531,6 +23531,10 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
}
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;
if ((!otherTypedValue->mType->IsSigned()) && (otherTypedValue->mType->mSize < mModule->mSystem->mPtrSize))
addValue = mModule->mBfIRBuilder->CreateNumericCast(addValue, false, BfTypeCode_UIntPtr);