Commit a7c3d5e4ec

Robin Voetter <robin@voetter.nl>
2023-09-23 01:46:00
spirv: constant elem ptr fix
1 parent 4ea361f
Changed files (2)
src
codegen
test
behavior
src/codegen/spirv.zig
@@ -784,11 +784,12 @@ pub const DeclGen = struct {
             .opt_payload => unreachable, // TODO
             .comptime_field => unreachable,
             .elem => |elem_ptr| {
-                const elem_ptr_ty = mod.intern_pool.typeOf(elem_ptr.base).toType();
-                const parent_ptr_id = try self.constantPtr(elem_ptr_ty, elem_ptr.base.toValue());
+                const parent_ptr_ty = mod.intern_pool.typeOf(elem_ptr.base).toType();
+                const parent_ptr_id = try self.constantPtr(parent_ptr_ty, elem_ptr.base.toValue());
                 const size_ty_ref = try self.sizeType();
                 const index_id = try self.constInt(size_ty_ref, elem_ptr.index);
-                return self.ptrAccessChain(result_ty_ref, parent_ptr_id, index_id, &.{});
+
+                return try self.ptrElemPtr(parent_ptr_ty, parent_ptr_id, index_id);
             },
             .field => unreachable, // TODO
         }
test/behavior/slice.zig
@@ -219,7 +219,6 @@ test "slice string literal has correct type" {
 
 test "result location zero sized array inside struct field implicit cast to slice" {
     if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
-    if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
 
     const E = struct {
         entries: []u32,