CBE: fix renderValue() for struct fields with no runtime bits

These shouldn't count towards the total emitted, or the stray comma
separators would cause compilation errors.
This commit is contained in:
Daniele Cocca 2022-04-28 22:59:16 +01:00 committed by Andrew Kelley
parent 2409041e62
commit fda143d5d8
2 changed files with 4 additions and 3 deletions

View File

@ -821,12 +821,14 @@ pub const DeclGen = struct {
try dg.renderTypecast(writer, ty);
try writer.writeAll("){");
for (field_vals) |field_val, i| {
const field_ty = ty.structFieldType(i);
var i: usize = 0;
for (field_vals) |field_val, field_index| {
const field_ty = ty.structFieldType(field_index);
if (!field_ty.hasRuntimeBits()) continue;
if (i != 0) try writer.writeAll(",");
try dg.renderValue(writer, field_ty, field_val, location);
i += 1;
}
try writer.writeAll("}");

View File

@ -299,7 +299,6 @@ test "struct point to self" {
test "void struct fields" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
const foo = VoidStructFieldsFoo{