commit 4a6454fb8d910a22d888262ea80165ec24c9f190 (tree)
parent 2f0204aca303daf899a97c740719a62398adc206
Author: David Martschenko <david.martschenko@web.de>
Date: Sat, 19 Feb 2022 12:37:46 +0100
C backend: fix codegen for field_ptr/elem_ptr values
Diffstat:
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
@@ -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();
diff --git a/test/behavior.zig b/test/behavior.zig
@@ -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");