| author | |
| committer | |
| log | 02692ad78cbdc1086abc4e37739e512c9203f486 |
| tree | 24805abd8c8d59ce75c8de4c057482a7e1dc5399 |
| parent | 4e581427d1fee46cdcab088cb2c1d7ad51b06239 |
5 files changed, 56 insertions(+), 8 deletions(-)
src/Compilation.zig+6-1| ... | ... | @@ -251,7 +251,12 @@ reference_trace: ?u32 = null, |
| 251 | 251 | libcxx_abi_version: libcxx.AbiVersion = libcxx.AbiVersion.default, |
| 252 | 252 | |
| 253 | 253 | /// This mutex guards all `Compilation` mutable state. |
| 254 | mutex: std.Thread.Mutex = .{}, | |
| 254 | /// Disabled in single-threaded mode because the thread pool spawns in the same thread. | |
| 255 | mutex: if (builtin.single_threaded) struct { | |
| 256 | pub inline fn tryLock(_: @This()) void {} | |
| 257 | pub inline fn lock(_: @This()) void {} | |
| 258 | pub inline fn unlock(_: @This()) void {} | |
| 259 | } else std.Thread.Mutex = .{}, | |
| 255 | 260 | |
| 256 | 261 | test_filters: []const []const u8, |
| 257 | 262 | test_name_prefix: ?[]const u8, |
src/InternPool.zig+11-6| ... | ... | @@ -5538,7 +5538,7 @@ pub const Tag = enum(u8) { |
| 5538 | 5538 | }, |
| 5539 | 5539 | }, |
| 5540 | 5540 | .type_union = .{ |
| 5541 | .summary = .@"{.payload.name%summary#\"#\"}", | |
| 5541 | .summary = .@"{.payload.name%summary#\"}", | |
| 5542 | 5542 | .payload = TypeUnion, |
| 5543 | 5543 | .trailing = struct { |
| 5544 | 5544 | captures_len: ?u32, |
| ... | ... | @@ -6584,7 +6584,7 @@ pub fn init(ip: *InternPool, gpa: Allocator, available_threads: usize) !void { |
| 6584 | 6584 | } |
| 6585 | 6585 | |
| 6586 | 6586 | pub fn deinit(ip: *InternPool, gpa: Allocator) void { |
| 6587 | if (!builtin.strip_debug_info) std.debug.assert(debug_state.intern_pool == null); | |
| 6587 | if (debug_state.enable_checks) std.debug.assert(debug_state.intern_pool == null); | |
| 6588 | 6588 | |
| 6589 | 6589 | ip.file_deps.deinit(gpa); |
| 6590 | 6590 | ip.src_hash_deps.deinit(gpa); |
| ... | ... | @@ -6629,7 +6629,7 @@ pub fn deinit(ip: *InternPool, gpa: Allocator) void { |
| 6629 | 6629 | } |
| 6630 | 6630 | |
| 6631 | 6631 | pub fn activate(ip: *const InternPool) void { |
| 6632 | if (builtin.strip_debug_info) return; | |
| 6632 | if (!debug_state.enable) return; | |
| 6633 | 6633 | _ = Index.Unwrapped.debug_state; |
| 6634 | 6634 | _ = String.debug_state; |
| 6635 | 6635 | _ = OptionalString.debug_state; |
| ... | ... | @@ -6639,18 +6639,23 @@ pub fn activate(ip: *const InternPool) void { |
| 6639 | 6639 | _ = TrackedInst.Index.Optional.debug_state; |
| 6640 | 6640 | _ = Nav.Index.debug_state; |
| 6641 | 6641 | _ = Nav.Index.Optional.debug_state; |
| 6642 | std.debug.assert(debug_state.intern_pool == null); | |
| 6642 | if (debug_state.enable_checks) std.debug.assert(debug_state.intern_pool == null); | |
| 6643 | 6643 | debug_state.intern_pool = ip; |
| 6644 | 6644 | } |
| 6645 | 6645 | |
| 6646 | 6646 | pub fn deactivate(ip: *const InternPool) void { |
| 6647 | if (builtin.strip_debug_info) return; | |
| 6647 | if (!debug_state.enable) return; | |
| 6648 | 6648 | std.debug.assert(debug_state.intern_pool == ip); |
| 6649 | debug_state.intern_pool = null; | |
| 6649 | if (debug_state.enable_checks) debug_state.intern_pool = null; | |
| 6650 | 6650 | } |
| 6651 | 6651 | |
| 6652 | 6652 | /// For debugger access only. |
| 6653 | 6653 | const debug_state = struct { |
| 6654 | const enable = switch (builtin.zig_backend) { | |
| 6655 | else => false, | |
| 6656 | .stage2_x86_64 => !builtin.strip_debug_info, | |
| 6657 | }; | |
| 6658 | const enable_checks = enable and !builtin.single_threaded; | |
| 6654 | 6659 | threadlocal var intern_pool: ?*const InternPool = null; |
| 6655 | 6660 | }; |
| 6656 | 6661 |
src/codegen/c.zig+20-1| ... | ... | @@ -7419,7 +7419,9 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7419 | 7419 | .@"packed" => { |
| 7420 | 7420 | try f.writeCValue(writer, local, .Other); |
| 7421 | 7421 | try writer.writeAll(" = "); |
| 7422 | const int_info = inst_ty.intInfo(zcu); | |
| 7422 | ||
| 7423 | const backing_int_ty: Type = .fromInterned(loaded_struct.backingIntTypeUnordered(ip)); | |
| 7424 | const int_info = backing_int_ty.intInfo(zcu); | |
| 7423 | 7425 | |
| 7424 | 7426 | const bit_offset_ty = try pt.intType(.unsigned, Type.smallestUnsignedBits(int_info.bits - 1)); |
| 7425 | 7427 | |
| ... | ... | @@ -7450,6 +7452,12 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7450 | 7452 | try f.object.dg.renderTypeForBuiltinFnName(writer, inst_ty); |
| 7451 | 7453 | try writer.writeByte('('); |
| 7452 | 7454 | |
| 7455 | if (field_ty.isAbiInt(zcu)) { | |
| 7456 | try writer.writeAll("zig_and_"); | |
| 7457 | try f.object.dg.renderTypeForBuiltinFnName(writer, inst_ty); | |
| 7458 | try writer.writeByte('('); | |
| 7459 | } | |
| 7460 | ||
| 7453 | 7461 | if (inst_ty.isAbiInt(zcu) and (field_ty.isAbiInt(zcu) or field_ty.isPtrAtRuntime(zcu))) { |
| 7454 | 7462 | try f.renderIntCast(writer, inst_ty, element, .{}, field_ty, .FunctionArgument); |
| 7455 | 7463 | } else { |
| ... | ... | @@ -7467,6 +7475,17 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7467 | 7475 | try f.writeCValue(writer, element, .Other); |
| 7468 | 7476 | } |
| 7469 | 7477 | |
| 7478 | if (field_ty.isAbiInt(zcu)) { | |
| 7479 | try writer.writeAll(", "); | |
| 7480 | const field_int_info = field_ty.intInfo(zcu); | |
| 7481 | const field_mask = if (int_info.signedness == .signed and int_info.bits == field_int_info.bits) | |
| 7482 | try pt.intValue(backing_int_ty, -1) | |
| 7483 | else | |
| 7484 | try (try pt.intType(.unsigned, field_int_info.bits)).maxIntScalar(pt, backing_int_ty); | |
| 7485 | try f.object.dg.renderValue(writer, field_mask, .FunctionArgument); | |
| 7486 | try writer.writeByte(')'); | |
| 7487 | } | |
| 7488 | ||
| 7470 | 7489 | try writer.print(", {}", .{ |
| 7471 | 7490 | try f.fmtIntLiteral(try pt.intValue(bit_offset_ty, bit_offset)), |
| 7472 | 7491 | }); |
test/behavior/export_keyword.zig+2| ... | ... | @@ -41,6 +41,8 @@ export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void { |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | test "export function alias" { |
| 44 | if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest; | |
| 45 | ||
| 44 | 46 | _ = struct { |
| 45 | 47 | fn foo_internal() callconv(.C) u32 { |
| 46 | 48 | return 123; |
test/behavior/packed-struct.zig+17| ... | ... | @@ -1327,3 +1327,20 @@ test "packed struct with signed field" { |
| 1327 | 1327 | try expect(s.a == -1); |
| 1328 | 1328 | try expect(s.b == 42); |
| 1329 | 1329 | } |
| 1330 | ||
| 1331 | test "assign packed struct initialized with RLS to packed struct literal field" { | |
| 1332 | if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isWasm()) return error.SkipZigTest; | |
| 1333 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 1334 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | |
| 1335 | ||
| 1336 | const Inner = packed struct { x: u17 }; | |
| 1337 | const Outer = packed struct { inner: Inner, x: u15 }; | |
| 1338 | ||
| 1339 | var x: u15 = undefined; | |
| 1340 | x = 23385; | |
| 1341 | var inner: Inner = undefined; | |
| 1342 | inner = .{ .x = x }; | |
| 1343 | const outer = Outer{ .x = x, .inner = inner }; | |
| 1344 | try expect(outer.inner.x == x); | |
| 1345 | try expect(outer.x == x); | |
| 1346 | } |