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/diagnostics | |
| 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/diagnostics')
| -rw-r--r-- | tests/diagnostics/uninitialized-local-variables.slang | 26 |
1 files changed, 26 insertions, 0 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 |
