cbe: add missing cast for @intToPtr values

This commit is contained in:
Jacob Young 2023-06-15 01:30:06 -04:00 committed by Andrew Kelley
parent 1253d591be
commit 2d6d2a1d11
2 changed files with 9 additions and 5 deletions

View File

@ -345,12 +345,13 @@ pub fn print(
try writer.print("[{}]", .{elem.index});
},
.field => |field| {
const container_ty = ip.typeOf(field.base).toType();
const ptr_container_ty = ip.typeOf(field.base).toType();
try print(.{
.ty = container_ty,
.ty = ptr_container_ty,
.val = field.base.toValue(),
}, writer, level - 1, mod);
const container_ty = ptr_container_ty.childType(mod);
switch (container_ty.zigTypeTag(mod)) {
.Struct => {
if (container_ty.isTuple(mod)) {
@ -375,6 +376,7 @@ pub fn print(
}
},
}
return;
},
.opt => |opt| switch (opt.val) {
.none => return writer.writeAll("null"),

View File

@ -596,9 +596,11 @@ pub const DeclGen = struct {
},
location,
),
.int => |int| try writer.print("{x}", .{
try dg.fmtIntLiteral(Type.usize, int.toValue(), .Other),
}),
.int => |int| {
try writer.writeByte('(');
try dg.renderCType(writer, ptr_cty);
try writer.print("){x}", .{try dg.fmtIntLiteral(Type.usize, int.toValue(), .Other)});
},
.eu_payload, .opt_payload => |base| {
const ptr_base_ty = mod.intern_pool.typeOf(base).toType();
const base_ty = ptr_base_ty.childType(mod);