| author | |
| committer | |
| log | 3ca4925709ac6369391eb40616de33051e0bb1f1 |
| tree | 61b0e83b961a8e5f7f13a0d4ec92f5b3730101fd |
| parent | 99112b5d4ac885f63a79c6f7926f92ff4f3ce819 |
| parent | 9050a07540b7387dade8184d3a3daf957e805e4f |
| signature |
closes #27014 files changed, 14 insertions(+), 9 deletions(-)
src/ir.cpp+3-1| ... | ... | @@ -16794,7 +16794,9 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 16794 | 16794 | case ZigTypeIdPromise: |
| 16795 | 16795 | case ZigTypeIdVector: |
| 16796 | 16796 | { |
| 16797 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusAlignmentKnown))) | |
| 16797 | ResolveStatus needed_status = (align_bytes == 0) ? | |
| 16798 | ResolveStatusZeroBitsKnown : ResolveStatusAlignmentKnown; | |
| 16799 | if ((err = type_resolve(ira->codegen, child_type, needed_status))) | |
| 16798 | 16800 | return ira->codegen->invalid_instruction; |
| 16799 | 16801 | ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, child_type, |
| 16800 | 16802 | is_const, is_volatile, PtrLenUnknown, align_bytes, 0, 0, is_allow_zero); |
test/stage1/behavior.zig-1| ... | ... | @@ -27,7 +27,6 @@ comptime { |
| 27 | 27 | _ = @import("behavior/bugs/2114.zig"); |
| 28 | 28 | _ = @import("behavior/bugs/2346.zig"); |
| 29 | 29 | _ = @import("behavior/bugs/2578.zig"); |
| 30 | _ = @import("behavior/bugs/2689.zig"); | |
| 31 | 30 | _ = @import("behavior/bugs/394.zig"); |
| 32 | 31 | _ = @import("behavior/bugs/421.zig"); |
| 33 | 32 | _ = @import("behavior/bugs/529.zig"); |
test/stage1/behavior/bugs/2689.zig deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | test "slice with alignment" { | |
| 2 | const S = packed struct { | |
| 3 | a: u8, | |
| 4 | }; | |
| 5 | ||
| 6 | var a: []align(8) S = undefined; | |
| 7 | } |
test/stage1/behavior/slice.zig+11| ... | ... | @@ -54,3 +54,14 @@ test "comptime slices are disambiguated" { |
| 54 | 54 | expect(sliceSum([_]u8{ 1, 2 }) == 3); |
| 55 | 55 | expect(sliceSum([_]u8{ 3, 4 }) == 7); |
| 56 | 56 | } |
| 57 | ||
| 58 | test "slice type with custom alignment" { | |
| 59 | const LazilyResolvedType = struct { | |
| 60 | anything: i32, | |
| 61 | }; | |
| 62 | var slice: []align(32) LazilyResolvedType = undefined; | |
| 63 | var array: [10]LazilyResolvedType align(32) = undefined; | |
| 64 | slice = &array; | |
| 65 | slice[1].anything = 42; | |
| 66 | expect(array[1].anything == 42); | |
| 67 | } |