diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2024-06-04 10:26:12 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-04 10:26:12 -0700 |
| commit | 9b6b31be5b38c588bde28d5f215d78cfc62620da (patch) | |
| tree | 03330e5f920c7f7c45375ddbac8ff449cbbcbe01 /tests/diagnostics | |
| parent | 89c1fd0dd1581221f583653a9dfa6d1cf990577c (diff) | |
Print warning when operator<< shifting too much (#4255)
* Print warning when operator<< shifting too much
Closes #3944
For the given type of the left side operand to `operator<<` is not big
enough for the right side operand, print a warning that the result will
be always zero.
Diffstat (limited to 'tests/diagnostics')
| -rw-r--r-- | tests/diagnostics/warning_operator_left_shift_overflow.slang | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/diagnostics/warning_operator_left_shift_overflow.slang b/tests/diagnostics/warning_operator_left_shift_overflow.slang new file mode 100644 index 000000000..5c156a9b9 --- /dev/null +++ b/tests/diagnostics/warning_operator_left_shift_overflow.slang @@ -0,0 +1,27 @@ +//TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target hlsl + +RWStructuredBuffer<int> inputBuffer; +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) +{ + uint8_t u8 = uint8_t(inputBuffer[0]); + + uint result = (u8 << 0) + + (u8 << 1) + + (u8 << 2) + + (u8 << 3) + + (u8 << 4) + + (u8 << 5) + + (u8 << 6) + + (u8 << 7) + // CHECK-NOT: warning 41030: + // CHECK: ([[#@LINE+1]]): warning 41030: {{.*}}uint8{{.*}}8 + + (u8 << 8) + // CHECK: ([[#@LINE+1]]): warning 41030: {{.*}}uint8{{.*}}9 + + (u8 << 9) + ; + + outputBuffer[0] = int(result); +} |
