diff options
| author | venkataram-nv <vedavamadath@nvidia.com> | 2024-07-09 16:18:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-09 16:18:36 -0700 |
| commit | 0e6c5c518953141f31c09e5f10d3939054f9b1ee (patch) | |
| tree | 932bddc80408e211e1128ca5901b301c154e67bd /tests/bugs | |
| parent | 1caef5907d0b0f16f686a8fcca479c6afc09f146 (diff) | |
Warnings for uninitialized values (#4530)
This extends the code for handling uninitialized output parameters.
Still needs to handle generic templates and assignment of uninitialized
values more carefully.
The file containing the relevant code are now in
source/slang/slang-ir-use-uninitialized-values.cpp
rather than the previous
source/slang/slang-ir-use-uninitialized-out-param.h
and the top-level function is now checkForUsingUinitializedValues.
Additionally a rudimentary test shader has been added for this case, which replaces the old file for out params only; tests/diagnositcs/uninitialized-out.slang becomes tests/diagnositcs/uninitialized.slang.
What this does not implement (could be future PRs):
* Checking uninitialized fields within constructors
* Partially uninitialized values with respect to data structure (e.g. arrays/structs/vector types)
* Partially uninitialized values with respect to control flow (e.g. if/else/loop)
Diffstat (limited to 'tests/bugs')
| -rw-r--r-- | tests/bugs/gh-4434.slang | 24 | ||||
| -rw-r--r-- | tests/bugs/gh-4441.slang | 24 |
2 files changed, 26 insertions, 22 deletions
diff --git a/tests/bugs/gh-4434.slang b/tests/bugs/gh-4434.slang index 975226008..c9a48d439 100644 --- a/tests/bugs/gh-4434.slang +++ b/tests/bugs/gh-4434.slang @@ -15,17 +15,19 @@ RWStructuredBuffer<uint> outputBuffer; [numthreads(4, 1, 1)] void computeMain(uint tid : SV_GroupIndex) { - bool a, b, c; - c = and(a, b); - - bool1 i, j, k; - bool2 l, m, n; - bool3 o, p, q; - bool4 r, s, t; - k = and(i, j); - n = and(m, l); - q = and(o, p); - t = and(r, s); + bool K = (bool)outputBuffer[tid]; + + bool c = and(K, K); + + bool1 K1 = K; + bool2 K2 = K; + bool3 K3 = K; + bool4 K4 = K; + + bool1 k = and(K, K); + bool2 n = and(K, K); + bool3 q = and(K, K); + bool4 t = and(K, K); k = !and(k, false); n = !and(n, false); diff --git a/tests/bugs/gh-4441.slang b/tests/bugs/gh-4441.slang index 59d577c8d..a2de7e00d 100644 --- a/tests/bugs/gh-4441.slang +++ b/tests/bugs/gh-4441.slang @@ -15,17 +15,19 @@ RWStructuredBuffer<uint> outputBuffer; [numthreads(4, 1, 1)] void computeMain(uint tid : SV_GroupIndex) { - bool a, b, c; - c = or(a, b); - - bool1 i, j, k; - bool2 l, m, n; - bool3 o, p, q; - bool4 r, s, t; - k = or(i, j); - n = or(m, l); - q = or(o, p); - t = or(r, s); + bool K = (bool)outputBuffer[tid]; + + bool c = or(K, K); + + bool1 K1 = K; + bool2 K2 = K; + bool3 K3 = K; + bool4 K4 = K; + + bool1 k = or(K, K); + bool2 n = or(K, K); + bool3 q = or(K, K); + bool4 t = or(K, K); k = or(k, true); n = or(n, true); |
