diff options
| author | venkataram-nv <vedavamadath@nvidia.com> | 2024-07-18 11:13:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-18 11:13:26 -0700 |
| commit | 1677a25f44d6f608c8aecd4e5c0ceeb94573c10e (patch) | |
| tree | e2202181d3783024b83a02f29c6716d4c0ada34a /tests | |
| parent | 0d06ebcefb36a19710d87832fc1ea027e21281af (diff) | |
Fix bug with uninititialized warnings in nested scopes (#4677)
Previously the warning system ignores undefined variables in nested scopes (blocks in IR).
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/diagnostics/uninitialized-local-variables.slang | 26 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/size-of/align-of-3.slang | 2 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/size-of/size-of-3.slang | 2 |
3 files changed, 28 insertions, 2 deletions
diff --git a/tests/diagnostics/uninitialized-local-variables.slang b/tests/diagnostics/uninitialized-local-variables.slang index 5a2119f53..3c3dba881 100644 --- a/tests/diagnostics/uninitialized-local-variables.slang +++ b/tests/diagnostics/uninitialized-local-variables.slang @@ -148,4 +148,30 @@ float structs() return result; } +// Warnings even in nested scopes +float nested_scopes(int x, inout float p) +{ + if (x == 0) + { + float y; + //CHK-DAG: warning 41016: use of uninitialized variable 'y' + return y; + } + else if (x == 1) + { + float y; + //CHK-DAG: warning 41016: use of uninitialized variable 'y' + p = y + 1; + + if (x == 2) + { + float z; + //CHK-DAG: warning 41016: use of uninitialized variable 'z' + p += z; + } + } + + return 1.0; +} + //CHK-NOT: warning 41016 diff --git a/tests/hlsl-intrinsic/size-of/align-of-3.slang b/tests/hlsl-intrinsic/size-of/align-of-3.slang index 064ea48e3..28665b5ab 100644 --- a/tests/hlsl-intrinsic/size-of/align-of-3.slang +++ b/tests/hlsl-intrinsic/size-of/align-of-3.slang @@ -24,7 +24,7 @@ int getParamSizeWithDirection(inout uint3 v) return alignof(v); } -struct TestThis +struct TestThis : IDefaultInitializable { int getSize() { diff --git a/tests/hlsl-intrinsic/size-of/size-of-3.slang b/tests/hlsl-intrinsic/size-of/size-of-3.slang index 26ef3f861..8a211867f 100644 --- a/tests/hlsl-intrinsic/size-of/size-of-3.slang +++ b/tests/hlsl-intrinsic/size-of/size-of-3.slang @@ -24,7 +24,7 @@ int getParamSizeWithDirection(inout uint3 v) return sizeof(v); } -struct TestThis +struct TestThis : IDefaultInitializable { int getSize() { |
