aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-04-25 23:48:03 -0700
committerGitHub <noreply@github.com>2023-04-25 23:48:03 -0700
commit13101295b93fe8ec5467bbd6cdf758a2bf823945 (patch)
tree18d88995a46b7b6d6d5fcb939463c27df1925eee /src/Module.zig
parent295b8ca467da36cd1066395e7f50b6245f456573 (diff)
parenta1fcb516928d1ba1106ea715acd1f6feba95e977 (diff)
downloadzig-13101295b93fe8ec5467bbd6cdf758a2bf823945.tar.gz
zig-13101295b93fe8ec5467bbd6cdf758a2bf823945.zip
Merge pull request #15454 from jacobly0/cbe-extern
cbe: implement `@extern`
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 27f7b24e7a..8460c243d7 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -6439,19 +6439,25 @@ pub fn populateTestFunctions(
errdefer new_decl_arena.deinit();
const arena = new_decl_arena.allocator();
- // This copy accesses the old Decl Type/Value so it must be done before `clearValues`.
- const new_ty = try Type.Tag.const_slice.create(arena, try tmp_test_fn_ty.copy(arena));
- const new_val = try Value.Tag.slice.create(arena, .{
- .ptr = try Value.Tag.decl_ref.create(arena, array_decl_index),
- .len = try Value.Tag.int_u64.create(arena, mod.test_functions.count()),
- });
+ {
+ // This copy accesses the old Decl Type/Value so it must be done before `clearValues`.
+ const new_ty = try Type.Tag.const_slice.create(arena, try tmp_test_fn_ty.copy(arena));
+ const new_var = try gpa.create(Var);
+ errdefer gpa.destroy(new_var);
+ new_var.* = decl.val.castTag(.variable).?.data.*;
+ new_var.init = try Value.Tag.slice.create(arena, .{
+ .ptr = try Value.Tag.decl_ref.create(arena, array_decl_index),
+ .len = try Value.Tag.int_u64.create(arena, mod.test_functions.count()),
+ });
+ const new_val = try Value.Tag.variable.create(arena, new_var);
- // Since we are replacing the Decl's value we must perform cleanup on the
- // previous value.
- decl.clearValues(mod);
- decl.ty = new_ty;
- decl.val = new_val;
- decl.has_tv = true;
+ // Since we are replacing the Decl's value we must perform cleanup on the
+ // previous value.
+ decl.clearValues(mod);
+ decl.ty = new_ty;
+ decl.val = new_val;
+ decl.has_tv = true;
+ }
try decl.finalizeNewArena(&new_decl_arena);
}