//TEST:SIMPLE(filecheck=CHECK):-stage compute -entry computeMain -target spirv // Tests pointer casting rules: Only explicit casting is allowed between pointer types. // All implicit conversions between pointer types should fail. int* processMemory; RWStructuredBuffer output; [numthreads(1, 1, 1)] void computeMain(int id : SV_DispatchThreadID) { // regular address-of // CHECK-NOT: ([[# @LINE+1]]): error Ptr rwPtr = processMemory + id.x; // copying a pointer of T* syntax // CHECK-NOT: ([[# @LINE+1]]): error Ptr copiedPtrOfLegacySyntax = processMemory; // casting to Read ptr // CHECK-NOT: ([[# @LINE+1]]): error Ptr rPtr = Ptr(processMemory + id.x); // casting to RW ptr from a R ptr // CHECK-NOT: ([[# @LINE+1]]): error Ptr p1 = Ptr(rPtr); // casting to R ptr from a RW ptr // CHECK-NOT: ([[# @LINE+1]]): error Ptr p2 = Ptr(rwPtr); // casting to ptr of different type // CHECK-NOT: ([[# @LINE+1]]): error Ptr p3 = Ptr(rPtr); // Cannot implicit cast ptr's // CHECK: ([[# @LINE+1]]): error 30019 Ptr p4 = rPtr; // cannot implcitly cast between different access qualifiers // CHECK: ([[# @LINE+1]]): error 30019 Ptr p5 = Ptr(processMemory + id.x); // cannot implcitly cast between different access qualifiers // CHECK: ([[# @LINE+1]]): error 30019 Ptr p6 = Ptr(processMemory + id.x); // TODO: Enable this when we allow user-defined group-shared address space, Issue #8173. // Cannot cast between different address spaces. // CHECK: ([[# @LINE+1]]): error Ptr p7 = Ptr(rwPtr); // CHECK: ([[# @LINE+1]]): error Ptr p8 = Ptr(p1); // CHECK: ([[# @LINE+1]]): error Ptr p9 = rwPtr; output[id] = *rwPtr; }