aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-06-01 01:25:01 -0400
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:47:58 -0700
commit123cfab98481554946208bd20a42ccc0c94681ef (patch)
tree6e8e6c5bb3269c1b68e4d6ad1b6256575cad0ca5 /src/codegen.zig
parent828756ceebaed09a90da81a5fc9a492443e2e8bb (diff)
downloadzig-123cfab98481554946208bd20a42ccc0c94681ef.tar.gz
zig-123cfab98481554946208bd20a42ccc0c94681ef.zip
codegen: fix doubled global sentinels
Diffstat (limited to 'src/codegen.zig')
-rw-r--r--src/codegen.zig46
1 files changed, 18 insertions, 28 deletions
diff --git a/src/codegen.zig b/src/codegen.zig
index a4c88d1258..b0febb5ea7 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -387,36 +387,26 @@ pub fn generateSymbol(
}
},
.aggregate => |aggregate| switch (mod.intern_pool.indexToKey(typed_value.ty.toIntern())) {
- .array_type => |array_type| {
- switch (aggregate.storage) {
- .bytes => |bytes| try code.appendSlice(bytes),
- .elems, .repeated_elem => {
- var index: u64 = 0;
- while (index < array_type.len) : (index += 1) {
- switch (try generateSymbol(bin_file, src_loc, .{
- .ty = array_type.child.toType(),
- .val = switch (aggregate.storage) {
- .bytes => unreachable,
- .elems => |elems| elems[@intCast(usize, index)],
- .repeated_elem => |elem| elem,
- }.toValue(),
- }, code, debug_output, reloc_info)) {
- .ok => {},
- .fail => |em| return .{ .fail = em },
- }
+ .array_type => |array_type| switch (aggregate.storage) {
+ .bytes => |bytes| try code.appendSlice(bytes),
+ .elems, .repeated_elem => {
+ var index: u64 = 0;
+ var len_including_sentinel =
+ array_type.len + @boolToInt(array_type.sentinel != .none);
+ while (index < len_including_sentinel) : (index += 1) {
+ switch (try generateSymbol(bin_file, src_loc, .{
+ .ty = array_type.child.toType(),
+ .val = switch (aggregate.storage) {
+ .bytes => unreachable,
+ .elems => |elems| elems[@intCast(usize, index)],
+ .repeated_elem => |elem| elem,
+ }.toValue(),
+ }, code, debug_output, reloc_info)) {
+ .ok => {},
+ .fail => |em| return .{ .fail = em },
}
- },
- }
-
- if (array_type.sentinel != .none) {
- switch (try generateSymbol(bin_file, src_loc, .{
- .ty = array_type.child.toType(),
- .val = array_type.sentinel.toValue(),
- }, code, debug_output, reloc_info)) {
- .ok => {},
- .fail => |em| return .{ .fail = em },
}
- }
+ },
},
.vector_type => |vector_type| {
switch (aggregate.storage) {