authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-06-15 01:30:06-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-15 14:06:49-07:00
log2d6d2a1d11bfca780e559303904571a93bace86b
treefcc7005ea3911834e61407f65a41a483e556ec47
parent1253d591be2aeea49c0b67ce0416237060e78a57

cbe: add missing cast for `@intToPtr` values


2 files changed, 9 insertions(+), 5 deletions(-)

src/TypedValue.zig+4-2
......@@ -345,12 +345,13 @@ pub fn print(
345345 try writer.print("[{}]", .{elem.index});
346346 },
347347 .field => |field| {
348 const container_ty = ip.typeOf(field.base).toType();
348 const ptr_container_ty = ip.typeOf(field.base).toType();
349349 try print(.{
350 .ty = container_ty,
350 .ty = ptr_container_ty,
351351 .val = field.base.toValue(),
352352 }, writer, level - 1, mod);
353353
354 const container_ty = ptr_container_ty.childType(mod);
354355 switch (container_ty.zigTypeTag(mod)) {
355356 .Struct => {
356357 if (container_ty.isTuple(mod)) {
......@@ -375,6 +376,7 @@ pub fn print(
375376 }
376377 },
377378 }
379 return;
378380 },
379381 .opt => |opt| switch (opt.val) {
380382 .none => return writer.writeAll("null"),
src/codegen/c.zig+5-3
......@@ -596,9 +596,11 @@ pub const DeclGen = struct {
596596 },
597597 location,
598598 ),
599 .int => |int| try writer.print("{x}", .{
600 try dg.fmtIntLiteral(Type.usize, int.toValue(), .Other),
601 }),
599 .int => |int| {
600 try writer.writeByte('(');
601 try dg.renderCType(writer, ptr_cty);
602 try writer.print("){x}", .{try dg.fmtIntLiteral(Type.usize, int.toValue(), .Other)});
603 },
602604 .eu_payload, .opt_payload => |base| {
603605 const ptr_base_ty = mod.intern_pool.typeOf(base).toType();
604606 const base_ty = ptr_base_ty.childType(mod);