C backend: fix codegen for field_ptr/elem_ptr values

This commit is contained in:
David Martschenko 2022-02-19 12:37:46 +01:00
parent 2f0204aca3
commit 4a6454fb8d
2 changed files with 5 additions and 5 deletions

View File

@ -464,7 +464,7 @@ pub const DeclGen = struct {
.variable => ptr_val.castTag(.variable).?.data.owner_decl,
else => unreachable,
};
try dg.renderDeclValue(writer, decl.ty, ptr_val, decl);
try dg.renderDeclName(decl, writer);
return decl.ty;
},
.field_ptr => {
@ -490,7 +490,7 @@ pub const DeclGen = struct {
},
.elem_ptr => {
const elem_ptr = ptr_val.castTag(.elem_ptr).?.data;
try writer.writeAll("&(*");
try writer.writeAll("&(");
const container_ty = try dg.renderChildPtr(writer, elem_ptr.array_ptr);
try writer.print(")[{d}]", .{elem_ptr.index});
return container_ty.childType();

View File

@ -100,19 +100,19 @@ test {
if (builtin.zig_backend != .stage2_wasm) {
// Tests that pass for stage1, llvm backend, C backend
_ = @import("behavior/bugs/9584.zig");
_ = @import("behavior/cast_int.zig");
_ = @import("behavior/eval.zig");
_ = @import("behavior/int128.zig");
_ = @import("behavior/merge_error_sets.zig");
_ = @import("behavior/translate_c_macros.zig");
if (builtin.zig_backend != .stage2_c) {
// Tests that pass for stage1 and the llvm backend.
_ = @import("behavior/atomics.zig");
_ = @import("behavior/bugs/9584.zig");
_ = @import("behavior/eval.zig");
_ = @import("behavior/floatop.zig");
_ = @import("behavior/math.zig");
_ = @import("behavior/maximum_minimum.zig");
_ = @import("behavior/merge_error_sets.zig");
_ = @import("behavior/popcount.zig");
_ = @import("behavior/saturating_arithmetic.zig");
_ = @import("behavior/sizeof_and_typeof.zig");