Skip to content

Commit

Permalink
Fixed failing test, fixed formatting and cleaned up code
Browse files Browse the repository at this point in the history
  • Loading branch information
fairywreath committed Dec 3, 2024
1 parent 33d5a5b commit a34827e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
7 changes: 5 additions & 2 deletions source/compiler-core/slang-lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,10 @@ static int _readOptionalBase(char const** ioCursor)
}


IntegerLiteralValue getIntegerLiteralValue(Token const& token, UnownedStringSlice* outSuffix, bool* outIsDecimalBase)
IntegerLiteralValue getIntegerLiteralValue(
Token const& token,
UnownedStringSlice* outSuffix,
bool* outIsDecimalBase)
{
IntegerLiteralValue value = 0;

Expand All @@ -698,7 +701,7 @@ IntegerLiteralValue getIntegerLiteralValue(Token const& token, UnownedStringSlic
*outSuffix = UnownedStringSlice(cursor, end);
}

if(outIsDecimalBase)
if (outIsDecimalBase)
{
*outIsDecimalBase = (base == 10);
}
Expand Down
18 changes: 7 additions & 11 deletions source/slang/slang-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6679,20 +6679,16 @@ static BaseType _determineNonSuffixedIntegerLiteralType(
if (isDecimalBase)
{
// There is an edge case here where 9223372036854775808 or INT64_MAX + 1
// brings us here, but the complete literal is -9223372036854775808 or INT64_MIN and is valid.
// Unfortunately because the lexer handles the negative(-) part of the literal separately
// it is impossible to know whether the literal has a negative sign or not.
// We emit the warning and initially process it as a uint64 anyways, and the negative sign
// will be properly parsed and the value will still be properly stored as a negative INT64_MIN.
// brings us here, but the complete literal is -9223372036854775808 or INT64_MIN and is
// valid. Unfortunately because the lexer handles the negative(-) part of the literal
// separately it is impossible to know whether the literal has a negative sign or not.
// We emit the warning and initially process it as a uint64 anyways, and the negative
// sign will be properly parsed and the value will still be properly stored as a
// negative INT64_MIN.

// Decimal integer is too large to be represented as signed.
// Output warning that it is represented as unsigned instead.
sink->diagnose(
*token,
Diagnostics::integerLiteralTooLarge,
token->getContent(),
BaseTypeInfo::asText(baseType),
rawValue);
sink->diagnose(*token, Diagnostics::integerLiteralTooLarge);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
// Bit logical
outputBuffer.InterlockedOrU64((idx << 3), (uint64_t(2) << 32) | (tid << 4));
outputBuffer.InterlockedXorU64((idx << 3), tid << 8);
outputBuffer.InterlockedAndU64((idx << 3), (uint64_t(tid | 2) << 32) | 0xffffffff);
outputBuffer.InterlockedAndU64((idx << 3), (uint64_t(tid | 2) << 32) | 0xffffffffffffffff);
}

0 comments on commit a34827e

Please sign in to comment.