File tree 3 files changed +30
-3
lines changed
3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -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,8 +6954,11 @@ 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
{
6961
+
6959
6962
// There is an edge case here where 9223372036854775808 or INT64_MAX + 1
6960
6963
// brings us here, but the complete literal is -9223372036854775808 or INT64_MIN and is
6961
6964
// valid. Unfortunately because the lexer handles the negative(-) part of the literal
Original file line number Diff line number Diff line change
1
+ // TEST:SIMPLE(filecheck=CHECK): -target dxbc-assembly
2
+
3
+ // Test that UINT64_MAX literals produce appropriate warnings
4
+ // This test verifies the fix from commit 0a3c1c8dbd6aa9501ea94a8de69d1a5967034b2c
5
+ // which ensures literals equivalent to UINT64_MAX produce appropriate warnings
6
+
7
+ void main()
8
+ {
9
+ // Decimal form of UINT64_MAX
10
+ // CHECK: warning 39999: integer literal is too large to be represented in a signed integer type, interpreting as unsigned
11
+ uint64_t a = 18446744073709551615 ;
12
+
13
+ // Hex form of UINT64_MAX
14
+ // CHECK: warning 39999: integer literal is too large to be represented in a signed integer type, interpreting as unsigned
15
+ uint64_t b = 0x FFFFFFFFFFFFFFFF ;
16
+
17
+ // Assigning UINT64_MAX to int - should also warn about size
18
+ // CHECK: warning 39999: integer literal is too large to be represented in a signed integer type, interpreting as unsigned
19
+ int c = 18446744073709551615 ;
20
+
21
+ // Also hex form to int
22
+ // CHECK: warning 39999: integer literal is too large to be represented in a signed integer type, interpreting as unsigned
23
+ int d = 0x FFFFFFFFFFFFFFFF ;
24
+ }
Original file line number Diff line number Diff line change @@ -32,6 +32,6 @@ void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
32
32
// Bit logical
33
33
outputBuffer .InterlockedOrU64 ((idx << 3 ), (uint64_t(2 ) << 32 ) | (tid << 4 ));
34
34
outputBuffer .InterlockedXorU64 ((idx << 3 ), tid << 8 );
35
- outputBuffer .InterlockedAndU64 ((idx << 3 ), (uint64_t(tid | 2 ) << 32 ) | 0x ffffffffffffffff );
35
+ outputBuffer .InterlockedAndU64 ((idx << 3 ), (uint64_t(tid | 2 ) << 32 ) | 0x ffffffffffffffff ULL );
36
36
}
37
37
You can’t perform that action at this time.
0 commit comments