diff options
| author | Yong He <yonghe@outlook.com> | 2024-03-21 17:19:03 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-21 17:19:03 -0700 |
| commit | 7a8ef896196ad0d7095412d8558dd9a2542874c8 (patch) | |
| tree | deef82a216f468fd57164f94700f2624164c7ca9 /tests | |
| parent | dd32414bd7332c55dc37ea2972ffcca73328d834 (diff) | |
Support arrow operator `->` on pointers. (#3812)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/diagnostics/arrow-operator.slang | 25 | ||||
| -rw-r--r-- | tests/spirv/pointer.slang | 2 |
2 files changed, 26 insertions, 1 deletions
diff --git a/tests/diagnostics/arrow-operator.slang b/tests/diagnostics/arrow-operator.slang new file mode 100644 index 000000000..8c370cf67 --- /dev/null +++ b/tests/diagnostics/arrow-operator.slang @@ -0,0 +1,25 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly + +struct Type +{ + int member; +} + +struct CB +{ + Type* ptr; +} +ConstantBuffer<CB> cb; + +[numthreads(1,1,1)] +void main() +{ + Type val; + + // CHECK: ([[# @LINE+1]]): error 30101 + val->member = 2; // Error. + + // CHECK-NOT: error + let a = cb->ptr->member; // OK. + +}
\ No newline at end of file diff --git a/tests/spirv/pointer.slang b/tests/spirv/pointer.slang index cd4845e4d..03ca3fb39 100644 --- a/tests/spirv/pointer.slang +++ b/tests/spirv/pointer.slang @@ -33,7 +33,7 @@ RWStructuredBuffer<int> output; void main(int id : SV_DispatchThreadID) { output[0] = buffer[0].pNext.data; - let pData = &(buffer[0].pNext.data); + let pData = &(buffer[0].pNext->data); // operator -> is also allowed on pointer types. // CHECK: OpPtrAccessChain int* pData1 = pData + 1; *pData1 = 3; |
