| #include <metal_stdlib> | |
| using namespace metal; | |
| void deref_const() { | |
| array<int, 10> a = {}; | |
| thread array<int, 10>* const p = (&a); | |
| int b = (*p)[0]; | |
| (*p)[0] = 42; | |
| } | |
| void no_deref_const() { | |
| array<int, 10> a = {}; | |
| thread array<int, 10>* const p = (&a); | |
| int b = (*p)[0]; | |
| (*p)[0] = 42; | |
| } | |
| void deref_let() { | |
| array<int, 10> a = {}; | |
| thread array<int, 10>* const p = (&a); | |
| int const i = 0; | |
| int b = (*p)[i]; | |
| (*p)[0] = 42; | |
| } | |
| void no_deref_let() { | |
| array<int, 10> a = {}; | |
| thread array<int, 10>* const p = (&a); | |
| int const i = 0; | |
| int b = (*p)[i]; | |
| (*p)[0] = 42; | |
| } | |
| void deref_var() { | |
| array<int, 10> a = {}; | |
| thread array<int, 10>* const p = (&a); | |
| int i = 0; | |
| int b = (*p)[min(uint(i), 9u)]; | |
| (*p)[0] = 42; | |
| } | |
| void no_deref_var() { | |
| array<int, 10> a = {}; | |
| thread array<int, 10>* const p = (&a); | |
| int i = 0; | |
| int b = (*p)[min(uint(i), 9u)]; | |
| (*p)[0] = 42; | |
| } | |
| [[max_total_threads_per_threadgroup(1)]] | |
| kernel void v() { | |
| (deref_const()); | |
| (no_deref_const()); | |
| (deref_let()); | |
| (no_deref_let()); | |
| (deref_var()); | |
| (no_deref_var()); | |
| } |