aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-10-28 15:59:14 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-10-28 15:59:14 -0700
commitd2f9646d98615d85589d2c46237559d1249f2765 (patch)
tree87c2297912251993970a282703f688c72932e228 /src/Module.zig
parent234d94e42b832dd17eb9144f5523e03ef4fa8eb3 (diff)
downloadzig-d2f9646d98615d85589d2c46237559d1249f2765.tar.gz
zig-d2f9646d98615d85589d2c46237559d1249f2765.zip
C backend: fix enough that zig test works
* test_functions: properly add dependencies of the array on test functions and test names so that the order comes out correctly. * fix lowering of struct literals to add parentheses around the type name. * omit const qualifier in slices because otherwise slices cannot be reassigned even when they are local variables. * special case pointer to functions and double pointer to functions in renderTypeAndName. This code will need to be cleaned up but for now it helps us make progress on other C backend stuff. * fix slice element access to lower to `.ptr[` instead of `[`. * airSliceElemVal: respect volatile slices
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig
index f0b3701e6e..1f394a0833 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -4734,6 +4734,10 @@ pub fn populateTestFunctions(mod: *Module) !void {
}),
.val = try Value.Tag.array.create(arena, test_fn_vals),
});
+
+ // Add a dependency on each test name and function pointer.
+ try array_decl.dependencies.ensureUnusedCapacity(gpa, test_fn_vals.len * 2);
+
for (mod.test_functions.keys()) |test_decl, i| {
const test_name_slice = mem.sliceTo(test_decl.name, 0);
const test_name_decl = n: {
@@ -4747,6 +4751,8 @@ pub fn populateTestFunctions(mod: *Module) !void {
try test_name_decl.finalizeNewArena(&name_decl_arena);
break :n test_name_decl;
};
+ array_decl.dependencies.putAssumeCapacityNoClobber(test_decl, {});
+ array_decl.dependencies.putAssumeCapacityNoClobber(test_name_decl, {});
try mod.linkerUpdateDecl(test_name_decl);
const field_vals = try arena.create([3]Value);