From 0d4a94f32fc71f81d54db038f013854b8e9f0ac4 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 13 Oct 2021 21:20:38 -0700 Subject: stage2: improve handling of 0-bit types and arrays * Make `alloc` AIR instructions call `resolveTypeLayout`. * `Sema.zirResolveInferredAlloc` now calls `requireRuntimeBlock` in the case that it operates on a non-comptime instruction. * `Type.abiSize` and `Type.abiAlignment` now return 0 for `void` * Sema: implement `resolveTypeFields` for unions. * LLVM Backend: support `ptr_elem_ptr` when the element type is 0-bit. * Type: improve `abiAlignment` implementation for structs to properly handle fields with non-default alignment. * Value: implement hashing array, vector, and structs. --- test/behavior/array.zig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/behavior/array.zig') diff --git a/test/behavior/array.zig b/test/behavior/array.zig index 7c2ab29280..0b4babca67 100644 --- a/test/behavior/array.zig +++ b/test/behavior/array.zig @@ -104,3 +104,11 @@ test "array with sentinels" { try S.doTheTest(false); comptime try S.doTheTest(true); } + +test "void arrays" { + var array: [4]void = undefined; + array[0] = void{}; + array[1] = array[2]; + try expect(@sizeOf(@TypeOf(array)) == 0); + try expect(array.len == 4); +} -- cgit v1.2.3