diff options
| -rw-r--r-- | source/slang/slang-ir-use-uninitialized-values.cpp | 6 | ||||
| -rw-r--r-- | tests/diagnostics/uninitialized-struct-from-constructor.slang | 24 |
2 files changed, 30 insertions, 0 deletions
diff --git a/source/slang/slang-ir-use-uninitialized-values.cpp b/source/slang/slang-ir-use-uninitialized-values.cpp index b48dadf8d..8661ba0dc 100644 --- a/source/slang/slang-ir-use-uninitialized-values.cpp +++ b/source/slang/slang-ir-use-uninitialized-values.cpp @@ -438,6 +438,12 @@ namespace Slang IRInst* user = use->getUser(); if (as<IRReturn>(user)) return true; + + // Loading from a Ptr type should be + // treated as an aliased path to any return + IRLoad *load = as<IRLoad>(user); + if (load && isReturnedValue(load)) + return true; } return false; } diff --git a/tests/diagnostics/uninitialized-struct-from-constructor.slang b/tests/diagnostics/uninitialized-struct-from-constructor.slang new file mode 100644 index 000000000..e3c44dca1 --- /dev/null +++ b/tests/diagnostics/uninitialized-struct-from-constructor.slang @@ -0,0 +1,24 @@ +//TEST:SIMPLE(filecheck=CHK): -target spirv + +struct TangentSpace +{ + static const float3 localNormal = {0, 1, 0}; + + float4x4 tangentTransform; + float3 geometryNormal; + + __init(in float3 normal, in float3 inRay) + { + // Should not warn here + tangentTransform = getMatrix(normal, inRay); + geometryNormal = localNormal; + } + + float4x4 getMatrix(in float3 normal, in float3 inRay) + { + return float4x4(0.0f); + } +} + +//CHK-NOT: warning 41020 +//CHK-NOT: warning 41021
\ No newline at end of file |
