diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/diagnostics/uninitialized-resource-field.slang | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/diagnostics/uninitialized-resource-field.slang b/tests/diagnostics/uninitialized-resource-field.slang new file mode 100644 index 000000000..b2e87effb --- /dev/null +++ b/tests/diagnostics/uninitialized-resource-field.slang @@ -0,0 +1,26 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target hlsl + +RWStructuredBuffer<int> outputBuffer; + +void useStruct(SomeStruct s) +{ + outputBuffer[0] = s.value; +} + +[shader("compute")] +[numthreads(1,1,1)] +void computeMain(uint3 threadId : SV_DispatchThreadID) +{ + // CHECK: ([[# @LINE+1]]): error {{.*}} cannot default-initialize struct 'SomeStruct' with '{}' because it contains an uninitialized texture field + SomeStruct s = {}; + + s.value = 10 + threadId.x; + useStruct(s); +} + +// CHECK: ([[# @LINE+1]]): note: see definition of struct 'SomeStruct' +struct SomeStruct +{ + int value; + Texture1D<float> tex; +} |
