| author | |
| committer | |
| log | 33cf6ef621114daad63d14067b6ff374e664d410 |
| tree | 9828aa24009a7f03a446433606c46e14f5667587 |
| parent | b66247c97af3deaa190d1ca8297166f932b022ff |
| parent | 28986a059075c2dce662c2f4e823b3efd283df87 |
| signature |
Stage2: fixes for bugs found while looking for miscompilations5 files changed, 48 insertions(+), 12 deletions(-)
lib/std/bit_set.zig-4| ... | ... | @@ -1330,7 +1330,6 @@ fn testStaticBitSet(comptime Set: type) !void { |
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | 1332 | test "IntegerBitSet" { |
| 1333 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 1334 | 1333 | try testStaticBitSet(IntegerBitSet(0)); |
| 1335 | 1334 | try testStaticBitSet(IntegerBitSet(1)); |
| 1336 | 1335 | try testStaticBitSet(IntegerBitSet(2)); |
| ... | ... | @@ -1342,7 +1341,6 @@ test "IntegerBitSet" { |
| 1342 | 1341 | } |
| 1343 | 1342 | |
| 1344 | 1343 | test "ArrayBitSet" { |
| 1345 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 1346 | 1344 | if (@import("builtin").cpu.arch == .aarch64) { |
| 1347 | 1345 | // https://github.com/ziglang/zig/issues/9879 |
| 1348 | 1346 | return error.SkipZigTest; |
| ... | ... | @@ -1357,7 +1355,6 @@ test "ArrayBitSet" { |
| 1357 | 1355 | } |
| 1358 | 1356 | |
| 1359 | 1357 | test "DynamicBitSetUnmanaged" { |
| 1360 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 1361 | 1358 | const allocator = std.testing.allocator; |
| 1362 | 1359 | var a = try DynamicBitSetUnmanaged.initEmpty(allocator, 300); |
| 1363 | 1360 | try testing.expectEqual(@as(usize, 0), a.count()); |
| ... | ... | @@ -1398,7 +1395,6 @@ test "DynamicBitSetUnmanaged" { |
| 1398 | 1395 | } |
| 1399 | 1396 | |
| 1400 | 1397 | test "DynamicBitSet" { |
| 1401 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 1402 | 1398 | const allocator = std.testing.allocator; |
| 1403 | 1399 | var a = try DynamicBitSet.initEmpty(allocator, 300); |
| 1404 | 1400 | try testing.expectEqual(@as(usize, 0), a.count()); |
lib/std/tz.zig+1-4| ... | ... | @@ -11,7 +11,7 @@ pub const Timetype = struct { |
| 11 | 11 | flags: u8, |
| 12 | 12 | name_data: [6:0]u8, |
| 13 | 13 | |
| 14 | pub fn name(self: Timetype) [:0]const u8 { | |
| 14 | pub fn name(self: *const Timetype) [:0]const u8 { | |
| 15 | 15 | return std.mem.sliceTo(self.name_data[0..], 0); |
| 16 | 16 | } |
| 17 | 17 | |
| ... | ... | @@ -214,7 +214,6 @@ pub const Tz = struct { |
| 214 | 214 | }; |
| 215 | 215 | |
| 216 | 216 | test "slim" { |
| 217 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 218 | 217 | const data = @embedFile("tz/asia_tokyo.tzif"); |
| 219 | 218 | var in_stream = std.io.fixedBufferStream(data); |
| 220 | 219 | |
| ... | ... | @@ -228,7 +227,6 @@ test "slim" { |
| 228 | 227 | } |
| 229 | 228 | |
| 230 | 229 | test "fat" { |
| 231 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 232 | 230 | const data = @embedFile("tz/antarctica_davis.tzif"); |
| 233 | 231 | var in_stream = std.io.fixedBufferStream(data); |
| 234 | 232 | |
| ... | ... | @@ -241,7 +239,6 @@ test "fat" { |
| 241 | 239 | } |
| 242 | 240 | |
| 243 | 241 | test "legacy" { |
| 244 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 245 | 242 | // Taken from Slackware 8.0, from 2001 |
| 246 | 243 | const data = @embedFile("tz/europe_vatican.tzif"); |
| 247 | 244 | var in_stream = std.io.fixedBufferStream(data); |
src/Sema.zig+35-3| ... | ... | @@ -3795,6 +3795,32 @@ fn zirValidateArrayInit( |
| 3795 | 3795 | } |
| 3796 | 3796 | continue; |
| 3797 | 3797 | }, |
| 3798 | .bitcast => { | |
| 3799 | // %a = bitcast(*arr_ty, %array_base) | |
| 3800 | // %b = ptr_elem_ptr(%a, %index) | |
| 3801 | // %c = bitcast(*elem_ty, %b) | |
| 3802 | // %d = store(%c, %val) | |
| 3803 | if (air_datas[next_air_inst].ty_op.operand != elem_ptr_air_ref) { | |
| 3804 | array_is_comptime = false; | |
| 3805 | continue; | |
| 3806 | } | |
| 3807 | const store_inst = block.instructions.items[block_index + 2]; | |
| 3808 | if (air_tags[store_inst] != .store) { | |
| 3809 | array_is_comptime = false; | |
| 3810 | continue; | |
| 3811 | } | |
| 3812 | const bin_op = air_datas[store_inst].bin_op; | |
| 3813 | if (bin_op.lhs != Air.indexToRef(next_air_inst)) { | |
| 3814 | array_is_comptime = false; | |
| 3815 | continue; | |
| 3816 | } | |
| 3817 | if (try sema.resolveMaybeUndefValAllowVariables(block, elem_src, bin_op.rhs)) |val| { | |
| 3818 | element_vals[i] = val; | |
| 3819 | } else { | |
| 3820 | array_is_comptime = false; | |
| 3821 | } | |
| 3822 | continue; | |
| 3823 | }, | |
| 3798 | 3824 | else => { |
| 3799 | 3825 | array_is_comptime = false; |
| 3800 | 3826 | continue; |
| ... | ... | @@ -21772,7 +21798,7 @@ fn coerceTupleToArray( |
| 21772 | 21798 | ) !Air.Inst.Ref { |
| 21773 | 21799 | const inst_ty = sema.typeOf(inst); |
| 21774 | 21800 | const inst_len = inst_ty.arrayLen(); |
| 21775 | const dest_len = try sema.usizeCast(block, dest_ty_src, dest_ty.arrayLen()); | |
| 21801 | const dest_len = dest_ty.arrayLen(); | |
| 21776 | 21802 | |
| 21777 | 21803 | if (dest_len != inst_len) { |
| 21778 | 21804 | const msg = msg: { |
| ... | ... | @@ -21787,13 +21813,19 @@ fn coerceTupleToArray( |
| 21787 | 21813 | return sema.failWithOwnedErrorMsg(block, msg); |
| 21788 | 21814 | } |
| 21789 | 21815 | |
| 21790 | const element_vals = try sema.arena.alloc(Value, dest_len); | |
| 21791 | const element_refs = try sema.arena.alloc(Air.Inst.Ref, dest_len); | |
| 21816 | const dest_elems = try sema.usizeCast(block, dest_ty_src, dest_ty.arrayLenIncludingSentinel()); | |
| 21817 | const element_vals = try sema.arena.alloc(Value, dest_elems); | |
| 21818 | const element_refs = try sema.arena.alloc(Air.Inst.Ref, dest_elems); | |
| 21792 | 21819 | const dest_elem_ty = dest_ty.childType(); |
| 21793 | 21820 | |
| 21794 | 21821 | var runtime_src: ?LazySrcLoc = null; |
| 21795 | 21822 | for (element_vals) |*elem, i_usize| { |
| 21796 | 21823 | const i = @intCast(u32, i_usize); |
| 21824 | if (i_usize == inst_len) { | |
| 21825 | elem.* = dest_ty.sentinel().?; | |
| 21826 | element_refs[i] = try sema.addConstant(dest_elem_ty, elem.*); | |
| 21827 | break; | |
| 21828 | } | |
| 21797 | 21829 | const elem_src = inst_src; // TODO better source location |
| 21798 | 21830 | const elem_ref = try tupleField(sema, block, inst_src, inst, elem_src, i); |
| 21799 | 21831 | const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src); |
src/value.zig+1-1| ... | ... | @@ -2186,7 +2186,7 @@ pub const Value = extern union { |
| 2186 | 2186 | // A tuple can be represented with .empty_struct_value, |
| 2187 | 2187 | // the_one_possible_value, .aggregate in which case we could |
| 2188 | 2188 | // end up here and the values are equal if the type has zero fields. |
| 2189 | return ty.structFieldCount() != 0; | |
| 2189 | return ty.isTupleOrAnonStruct() and ty.structFieldCount() != 0; | |
| 2190 | 2190 | }, |
| 2191 | 2191 | .Float => { |
| 2192 | 2192 | const a_nan = a.isNan(); |
test/behavior/array.zig+11| ... | ... | @@ -582,3 +582,14 @@ test "array with comptime only element type" { |
| 582 | 582 | try testing.expect(a[0] == u32); |
| 583 | 583 | try testing.expect(a[1] == i32); |
| 584 | 584 | } |
| 585 | ||
| 586 | test "tuple to array handles sentinel" { | |
| 587 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 588 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 589 | ||
| 590 | const S = struct { | |
| 591 | const a = .{ 1, 2, 3 }; | |
| 592 | var b: [3:0]u8 = a; | |
| 593 | }; | |
| 594 | try expect(S.b[0] == 1); | |
| 595 | } |