| author | |
| committer | |
| log | a1fcb516928d1ba1106ea715acd1f6feba95e977 |
| tree | 6449fdb37a56b6ceda045b91babffa41bc6f0bd2 |
| parent | f1782c07a9c1c66da843e6c7f345e9f004bc3b45 |
4 files changed, 21 insertions(+), 24 deletions(-)
src/Compilation.zig+1-1| ... | @@ -5265,7 +5265,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca | ... | @@ -5265,7 +5265,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca |
| 5265 | 5265 | ||
| 5266 | if (comp.bin_file.options.is_test) { | 5266 | if (comp.bin_file.options.is_test) { |
| 5267 | try buffer.appendSlice( | 5267 | try buffer.appendSlice( |
| 5268 | \\pub var test_functions: []std.builtin.TestFn = undefined; // overwritten later | 5268 | \\pub var test_functions: []const std.builtin.TestFn = undefined; // overwritten later |
| 5269 | \\ | 5269 | \\ |
| 5270 | ); | 5270 | ); |
| 5271 | if (comp.test_evented_io) { | 5271 | if (comp.test_evented_io) { |
src/Module.zig+18-12| ... | @@ -6439,19 +6439,25 @@ pub fn populateTestFunctions( | ... | @@ -6439,19 +6439,25 @@ pub fn populateTestFunctions( |
| 6439 | errdefer new_decl_arena.deinit(); | 6439 | errdefer new_decl_arena.deinit(); |
| 6440 | const arena = new_decl_arena.allocator(); | 6440 | const arena = new_decl_arena.allocator(); |
| 6441 | 6441 | ||
| 6442 | // This copy accesses the old Decl Type/Value so it must be done before `clearValues`. | 6442 | { |
| 6443 | const new_ty = try Type.Tag.const_slice.create(arena, try tmp_test_fn_ty.copy(arena)); | 6443 | // This copy accesses the old Decl Type/Value so it must be done before `clearValues`. |
| 6444 | const new_val = try Value.Tag.slice.create(arena, .{ | 6444 | const new_ty = try Type.Tag.const_slice.create(arena, try tmp_test_fn_ty.copy(arena)); |
| 6445 | .ptr = try Value.Tag.decl_ref.create(arena, array_decl_index), | 6445 | const new_var = try gpa.create(Var); |
| 6446 | .len = try Value.Tag.int_u64.create(arena, mod.test_functions.count()), | 6446 | errdefer gpa.destroy(new_var); |
| 6447 | }); | 6447 | new_var.* = decl.val.castTag(.variable).?.data.*; |
| 6448 | new_var.init = try Value.Tag.slice.create(arena, .{ | ||
| 6449 | .ptr = try Value.Tag.decl_ref.create(arena, array_decl_index), | ||
| 6450 | .len = try Value.Tag.int_u64.create(arena, mod.test_functions.count()), | ||
| 6451 | }); | ||
| 6452 | const new_val = try Value.Tag.variable.create(arena, new_var); | ||
| 6448 | 6453 | ||
| 6449 | // Since we are replacing the Decl's value we must perform cleanup on the | 6454 | // Since we are replacing the Decl's value we must perform cleanup on the |
| 6450 | // previous value. | 6455 | // previous value. |
| 6451 | decl.clearValues(mod); | 6456 | decl.clearValues(mod); |
| 6452 | decl.ty = new_ty; | 6457 | decl.ty = new_ty; |
| 6453 | decl.val = new_val; | 6458 | decl.val = new_val; |
| 6454 | decl.has_tv = true; | 6459 | decl.has_tv = true; |
| 6460 | } | ||
| 6455 | 6461 | ||
| 6456 | try decl.finalizeNewArena(&new_decl_arena); | 6462 | try decl.finalizeNewArena(&new_decl_arena); |
| 6457 | } | 6463 | } |
src/codegen/c/type.zig+1-11| ... | @@ -1720,17 +1720,7 @@ pub const CType = extern union { | ... | @@ -1720,17 +1720,7 @@ pub const CType = extern union { |
| 1720 | } else self.init(.anon_struct); | 1720 | } else self.init(.anon_struct); |
| 1721 | }, | 1721 | }, |
| 1722 | 1722 | ||
| 1723 | .Opaque => switch (ty.tag()) { | 1723 | .Opaque => self.init(.void), |
| 1724 | .anyopaque => self.init(.void), | ||
| 1725 | .@"opaque" => { | ||
| 1726 | self.storage = .{ .fwd = .{ | ||
| 1727 | .base = .{ .tag = .fwd_struct }, | ||
| 1728 | .data = ty.getOwnerDecl(), | ||
| 1729 | } }; | ||
| 1730 | self.value = .{ .cty = initPayload(&self.storage.fwd) }; | ||
| 1731 | }, | ||
| 1732 | else => unreachable, | ||
| 1733 | }, | ||
| 1734 | 1724 | ||
| 1735 | .Fn => { | 1725 | .Fn => { |
| 1736 | const info = ty.fnInfo(); | 1726 | const info = ty.fnInfo(); |
test/behavior/basic.zig+1| ... | @@ -774,6 +774,7 @@ test "extern variable with non-pointer opaque type" { | ... | @@ -774,6 +774,7 @@ test "extern variable with non-pointer opaque type" { |
| 774 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 774 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 775 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 775 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 776 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 776 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 777 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 777 | 778 | ||
| 778 | @export(var_to_export, .{ .name = "opaque_extern_var" }); | 779 | @export(var_to_export, .{ .name = "opaque_extern_var" }); |
| 779 | try expect(@ptrCast(*align(1) u32, &opaque_extern_var).* == 42); | 780 | try expect(@ptrCast(*align(1) u32, &opaque_extern_var).* == 42); |