| author | |
| committer | |
| log | dd66e0addb30d795a04324096c913ca89ccbcf40 |
| tree | 928cf49e81d9047d629ff40832719d40dd3cca0f |
| parent | 2b805526033b0446fba7f38990df707204e7e23a |
We just checked that inst_child_ty was effectively a zero-bit type, so
it is certainly not the non-zero alignment we are looking for.
Closes #150854 files changed, 20 insertions(+), 7 deletions(-)
src/Sema.zig+6-1| ... | @@ -25152,7 +25152,7 @@ fn coerceExtra( | ... | @@ -25152,7 +25152,7 @@ fn coerceExtra( |
| 25152 | .ptr = if (dest_info.@"align" != 0) | 25152 | .ptr = if (dest_info.@"align" != 0) |
| 25153 | try Value.Tag.int_u64.create(sema.arena, dest_info.@"align") | 25153 | try Value.Tag.int_u64.create(sema.arena, dest_info.@"align") |
| 25154 | else | 25154 | else |
| 25155 | try inst_child_ty.lazyAbiAlignment(target, sema.arena), | 25155 | try dest_info.pointee_type.lazyAbiAlignment(target, sema.arena), |
| 25156 | .len = Value.zero, | 25156 | .len = Value.zero, |
| 25157 | }); | 25157 | }); |
| 25158 | return sema.addConstant(dest_ty, slice_val); | 25158 | return sema.addConstant(dest_ty, slice_val); |
| ... | @@ -30213,6 +30213,11 @@ fn resolveLazyValue(sema: *Sema, val: Value) CompileError!void { | ... | @@ -30213,6 +30213,11 @@ fn resolveLazyValue(sema: *Sema, val: Value) CompileError!void { |
| 30213 | try sema.resolveLazyValue(elem_val); | 30213 | try sema.resolveLazyValue(elem_val); |
| 30214 | } | 30214 | } |
| 30215 | }, | 30215 | }, |
| 30216 | .slice => { | ||
| 30217 | const slice = val.castTag(.slice).?.data; | ||
| 30218 | try sema.resolveLazyValue(slice.ptr); | ||
| 30219 | return sema.resolveLazyValue(slice.len); | ||
| 30220 | }, | ||
| 30216 | else => return, | 30221 | else => return, |
| 30217 | } | 30222 | } |
| 30218 | } | 30223 | } |
src/codegen/c.zig+1-1| ... | @@ -1069,7 +1069,7 @@ pub const DeclGen = struct { | ... | @@ -1069,7 +1069,7 @@ pub const DeclGen = struct { |
| 1069 | const extern_fn = val.castTag(.extern_fn).?.data; | 1069 | const extern_fn = val.castTag(.extern_fn).?.data; |
| 1070 | try dg.renderDeclName(writer, extern_fn.owner_decl, 0); | 1070 | try dg.renderDeclName(writer, extern_fn.owner_decl, 0); |
| 1071 | }, | 1071 | }, |
| 1072 | .int_u64, .one => { | 1072 | .int_u64, .one, .int_big_positive, .lazy_align, .lazy_size => { |
| 1073 | try writer.writeAll("(("); | 1073 | try writer.writeAll("(("); |
| 1074 | try dg.renderType(writer, ty); | 1074 | try dg.renderType(writer, ty); |
| 1075 | return writer.print("){x})", .{try dg.fmtIntLiteral(Type.usize, val, .Other)}); | 1075 | return writer.print("){x})", .{try dg.fmtIntLiteral(Type.usize, val, .Other)}); |
src/codegen/llvm.zig+1-1| ... | @@ -3397,7 +3397,7 @@ pub const DeclGen = struct { | ... | @@ -3397,7 +3397,7 @@ pub const DeclGen = struct { |
| 3397 | }; | 3397 | }; |
| 3398 | return dg.context.constStruct(&fields, fields.len, .False); | 3398 | return dg.context.constStruct(&fields, fields.len, .False); |
| 3399 | }, | 3399 | }, |
| 3400 | .int_u64, .one, .int_big_positive => { | 3400 | .int_u64, .one, .int_big_positive, .lazy_align, .lazy_size => { |
| 3401 | const llvm_usize = try dg.lowerType(Type.usize); | 3401 | const llvm_usize = try dg.lowerType(Type.usize); |
| 3402 | const llvm_int = llvm_usize.constInt(tv.val.toUnsignedInt(target), .False); | 3402 | const llvm_int = llvm_usize.constInt(tv.val.toUnsignedInt(target), .False); |
| 3403 | return llvm_int.constIntToPtr(try dg.lowerType(tv.ty)); | 3403 | return llvm_int.constIntToPtr(try dg.lowerType(tv.ty)); |
test/behavior/slice.zig+12-4| ... | @@ -723,10 +723,18 @@ test "slice with dereferenced value" { | ... | @@ -723,10 +723,18 @@ test "slice with dereferenced value" { |
| 723 | test "empty slice ptr is non null" { | 723 | test "empty slice ptr is non null" { |
| 724 | if (builtin.zig_backend == .stage2_aarch64 and builtin.os.tag == .macos) return error.SkipZigTest; // TODO | 724 | if (builtin.zig_backend == .stage2_aarch64 and builtin.os.tag == .macos) return error.SkipZigTest; // TODO |
| 725 | 725 | ||
| 726 | const empty_slice: []u8 = &[_]u8{}; | 726 | { |
| 727 | const p: [*]u8 = empty_slice.ptr + 0; | 727 | const empty_slice: []u8 = &[_]u8{}; |
| 728 | const t = @ptrCast([*]i8, p); | 728 | const p: [*]u8 = empty_slice.ptr + 0; |
| 729 | try expect(@ptrToInt(t) == @ptrToInt(empty_slice.ptr)); | 729 | const t = @ptrCast([*]i8, p); |
| 730 | try expect(@ptrToInt(t) == @ptrToInt(empty_slice.ptr)); | ||
| 731 | } | ||
| 732 | { | ||
| 733 | const empty_slice: []u8 = &.{}; | ||
| 734 | const p: [*]u8 = empty_slice.ptr + 0; | ||
| 735 | const t = @ptrCast([*]i8, p); | ||
| 736 | try expect(@ptrToInt(t) == @ptrToInt(empty_slice.ptr)); | ||
| 737 | } | ||
| 730 | } | 738 | } |
| 731 | 739 | ||
| 732 | test "slice decays to many pointer" { | 740 | test "slice decays to many pointer" { |