diff options
| author | venkataram-nv <vedavamadath@nvidia.com> | 2024-08-28 14:42:14 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-28 14:42:14 -0700 |
| commit | d3a5a4723e0ba0f90ac3a0df3dd841d1f0c69782 (patch) | |
| tree | f7534d566b62761458620785b4e9515057d3043d /tests | |
| parent | 9192ee457e3553249726c9d39006a4cd281e5df4 (diff) | |
Ignoring construct field warnings on delegatory methods (#4911)
* Ignoring construct field warnings on delegatory methods
* Generalizing instruction usage type interface
* Skip collection when searching for stores
* Adding separate construct delegation tests
* Treating differentiable functions as stores
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/diagnostics/uninitialized-fields-delegated.slang | 46 | ||||
| -rw-r--r-- | tests/diagnostics/uninitialized-fields.slang | 18 |
2 files changed, 46 insertions, 18 deletions
diff --git a/tests/diagnostics/uninitialized-fields-delegated.slang b/tests/diagnostics/uninitialized-fields-delegated.slang new file mode 100644 index 000000000..e3777f477 --- /dev/null +++ b/tests/diagnostics/uninitialized-fields-delegated.slang @@ -0,0 +1,46 @@ +//TEST:SIMPLE(filecheck=CHK): -target spirv + +// Delegated constructors +struct Impl +{ + float x; + + __init(float val) + { + x = val; + } + + __init() + { + float val = 2.0; + + // Shouldn't trigger a warning here + return Impl(val); + } +} + +// Calling a method from a constructor to initialize fields +struct HitInfo +{ + float3 barycentrics; + uint primitiveIndex; + + [[mutating]] void init(float2 hitBarycentrics, uint hitPrimitiveIndex) + { + barycentrics = { 1.0 - hitBarycentrics.x - hitBarycentrics.y, hitBarycentrics.x, hitBarycentrics.y }; + primitiveIndex = hitPrimitiveIndex; + } + + __init(float2 hitBarycentrics, uint hitPrimitiveIndex) + { + init(hitBarycentrics, hitPrimitiveIndex); + } + + __init(BuiltInTriangleIntersectionAttributes attr) + { + init(attr.barycentrics, PrimitiveIndex()); + } +} + +//CHK-NOT: warning 41020 +//CHK-NOT: warning 41021 diff --git a/tests/diagnostics/uninitialized-fields.slang b/tests/diagnostics/uninitialized-fields.slang index 29e065d2b..c5fa37aad 100644 --- a/tests/diagnostics/uninitialized-fields.slang +++ b/tests/diagnostics/uninitialized-fields.slang @@ -86,23 +86,5 @@ struct Pass int y = 0; } -struct Impl -{ - float x; - - __init(float val) - { - x = val; - } - - __init() - { - float val = 2.0; - - // Shouldn't trigger a warning here - return Impl(val); - } -} - //CHK-NOT: warning 41020 //CHK-NOT: warning 41021 |
