mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed warnings for hex literals
This commit is contained in:
parent
12ed915194
commit
6975d1ce40
2 changed files with 9 additions and 14 deletions
|
@ -3059,10 +3059,10 @@ void BfExprEvaluator::Visit(BfLiteralExpression* literalExpr)
|
||||||
switch (literalExpr->mValue.mWarnType)
|
switch (literalExpr->mValue.mWarnType)
|
||||||
{
|
{
|
||||||
case BfWarning_BF4201_Only7Hex:
|
case BfWarning_BF4201_Only7Hex:
|
||||||
mModule->Warn(BfWarning_BF4201_Only7Hex, "Only 7 hex digits specified. Add a leading zero to clarify intention.", literalExpr);
|
mModule->Warn(BfWarning_BF4201_Only7Hex, "Only 7 hex digits specified. Add a leading zero to clarify intention.", literalExpr);
|
||||||
break;
|
break;
|
||||||
case BfWarning_BF4202_TooManyHexForInt:
|
case BfWarning_BF4202_TooManyHexForInt:
|
||||||
mModule->Warn(BfWarning_BF4202_TooManyHexForInt, "Too many hex digits for an int, but too few for a long. Use 'L' suffix if a long was intended.", literalExpr);
|
mModule->Warn(BfWarning_BF4202_TooManyHexForInt, "Nine hex digits specified. If an 8-digit hex literal was not intended then add a leading zero to clarify.", literalExpr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2440,6 +2440,12 @@ void BfParser::NextToken(int endIdx)
|
||||||
mLiteral.mInt64 = val;
|
mLiteral.mInt64 = val;
|
||||||
mLiteral.mTypeCode = BfTypeCode_IntUnknown;
|
mLiteral.mTypeCode = BfTypeCode_IntUnknown;
|
||||||
|
|
||||||
|
|
||||||
|
if ((numberBase == 0x10) && (hexDigits == 7))
|
||||||
|
mLiteral.mWarnType = BfWarning_BF4201_Only7Hex;
|
||||||
|
if ((numberBase == 0x10) && (hexDigits == 9))
|
||||||
|
mLiteral.mWarnType = BfWarning_BF4202_TooManyHexForInt;
|
||||||
|
|
||||||
if (hadOverflow)
|
if (hadOverflow)
|
||||||
{
|
{
|
||||||
mPassInstance->FailAt("Value doesn't fit into int64", mSourceData, mTokenStart, mSrcIdx - mTokenStart);
|
mPassInstance->FailAt("Value doesn't fit into int64", mSourceData, mTokenStart, mSrcIdx - mTokenStart);
|
||||||
|
@ -2448,18 +2454,7 @@ void BfParser::NextToken(int endIdx)
|
||||||
else if ((val < -0x80000000LL) || (val > 0xFFFFFFFFLL))
|
else if ((val < -0x80000000LL) || (val > 0xFFFFFFFFLL))
|
||||||
{
|
{
|
||||||
mLiteral.mTypeCode = BfTypeCode_Int64;
|
mLiteral.mTypeCode = BfTypeCode_Int64;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((numberBase == 0x10) && (hexDigits == 7))
|
|
||||||
mLiteral.mWarnType = BfWarning_BF4201_Only7Hex;
|
|
||||||
//mPassInstance->WarnAt(0, "Only 7 hex digits specified. Add a leading zero to clarify intention.", this, mTokenStart, mSrcIdx - mTokenStart);
|
|
||||||
if ((numberBase == 0x10) && (hexDigits > 8))
|
|
||||||
mLiteral.mWarnType = BfWarning_BF4202_TooManyHexForInt;
|
|
||||||
//mPassInstance->FailAt("Too many hex digits for an int, but too few for a long. Use 'L' suffix if a long was intended.", this, mTokenStart, mSrcIdx - mTokenStart);
|
|
||||||
/*if (val > 0x7FFFFFFF)
|
|
||||||
mLiteral.mTypeCode = BfTypeCode_UIntUnknown;*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mSyntaxToken = BfSyntaxToken_Literal;
|
mSyntaxToken = BfSyntaxToken_Literal;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue