@@ -6897,7 +6897,7 @@ static IntegerLiteralValue _fixIntegerLiteral(
6897
6897
// If the masked value is 0 or equal to the mask, we 'assume' no information is
6898
6898
// lost
6899
6899
// This allows for example -1u, to give 0xffffffff
6900
- // It also means 0xfffffffffffffffffu will give 0xffffffff, without a warning.
6900
+ // It also means 0xffffffffffffffffu will give 0xffffffff, without a warning.
6901
6901
if ((!(maskedValue == 0 || maskedValue == mask)) && sink && token)
6902
6902
{
6903
6903
// Output a warning that number has been altered
@@ -6954,16 +6954,10 @@ static BaseType _determineNonSuffixedIntegerLiteralType(
6954
6954
{
6955
6955
baseType = BaseType::UInt64 ;
6956
6956
6957
- if (isDecimalBase)
6957
+ // Emit warning if the value is too large for signed 64-bit, regardless of base
6958
+ // This fixes the inconsistency between decimal and hex literals
6959
+ if (sink && token)
6958
6960
{
6959
- // There is an edge case here where 9223372036854775808 or INT64_MAX + 1
6960
- // brings us here, but the complete literal is -9223372036854775808 or INT64_MIN and is
6961
- // valid. Unfortunately because the lexer handles the negative(-) part of the literal
6962
- // separately it is impossible to know whether the literal has a negative sign or not.
6963
- // We emit the warning and initially process it as a uint64 anyways, and the negative
6964
- // sign will be properly parsed and the value will still be properly stored as a
6965
- // negative INT64_MIN.
6966
-
6967
6961
// Decimal integer is too large to be represented as signed.
6968
6962
// Output warning that it is represented as unsigned instead.
6969
6963
sink->diagnose (*token, Diagnostics::integerLiteralTooLarge);
0 commit comments