From eda1b53723447c0fe0bc15bf29abcee2abe90153 Mon Sep 17 00:00:00 2001 From: xackus <14938807+xackus@users.noreply.github.com> Date: Fri, 5 Mar 2021 21:03:25 +0100 Subject: [PATCH] strip the leading zero from octal literals --- src/translate_c.zig | 2 +- test/translate_c.zig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/translate_c.zig b/src/translate_c.zig index 34655d3bb5..3656c1e244 100644 --- a/src/translate_c.zig +++ b/src/translate_c.zig @@ -4436,7 +4436,7 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!Node { switch (lit_bytes[1]) { '0'...'7' => { // Octal - lit_bytes = try std.fmt.allocPrint(c.arena, "0o{s}", .{lit_bytes}); + lit_bytes = try std.fmt.allocPrint(c.arena, "0o{s}", .{lit_bytes[1..]}); radix = "octal"; }, 'X' => { diff --git a/test/translate_c.zig b/test/translate_c.zig index 5785d07311..e8054c87ad 100644 --- a/test/translate_c.zig +++ b/test/translate_c.zig @@ -3410,6 +3410,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub const MAY_NEED_PROMOTION_2 = @import("std").meta.promoteIntLiteral(c_long, 307230723072, .decimal); \\pub const MAY_NEED_PROMOTION_3 = @import("std").meta.promoteIntLiteral(c_ulong, 819281928192, .decimal); \\pub const MAY_NEED_PROMOTION_HEX = @import("std").meta.promoteIntLiteral(c_int, 0x80000000, .hexadecimal); - \\pub const MAY_NEED_PROMOTION_OCT = @import("std").meta.promoteIntLiteral(c_int, 0o020000000000, .octal); + \\pub const MAY_NEED_PROMOTION_OCT = @import("std").meta.promoteIntLiteral(c_int, 0o20000000000, .octal); }); }