authorgravatar for 14938807+xackus@users.noreply.github.comxackus <14938807+xackus@users.noreply.github.com> 2021-03-05 21:03:25+01:00
committergravatar for 14938807+xackus@users.noreply.github.comxackus <14938807+xackus@users.noreply.github.com> 2021-03-05 21:21:23+01:00
logeda1b53723447c0fe0bc15bf29abcee2abe90153
tree0b244bcab6a2930d27af7d82fac7cc4ff6cdd8db
parenteee43a65aec2e2b104ff64cb23488a86437578e4

strip the leading zero from octal literals


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

src/translate_c.zig+1-1
......@@ -4436,7 +4436,7 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!Node {
44364436 switch (lit_bytes[1]) {
44374437 '0'...'7' => {
44384438 // Octal
4439 lit_bytes = try std.fmt.allocPrint(c.arena, "0o{s}", .{lit_bytes});
4439 lit_bytes = try std.fmt.allocPrint(c.arena, "0o{s}", .{lit_bytes[1..]});
44404440 radix = "octal";
44414441 },
44424442 'X' => {
test/translate_c.zig+1-1
......@@ -3410,6 +3410,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
34103410 \\pub const MAY_NEED_PROMOTION_2 = @import("std").meta.promoteIntLiteral(c_long, 307230723072, .decimal);
34113411 \\pub const MAY_NEED_PROMOTION_3 = @import("std").meta.promoteIntLiteral(c_ulong, 819281928192, .decimal);
34123412 \\pub const MAY_NEED_PROMOTION_HEX = @import("std").meta.promoteIntLiteral(c_int, 0x80000000, .hexadecimal);
3413 \\pub const MAY_NEED_PROMOTION_OCT = @import("std").meta.promoteIntLiteral(c_int, 0o020000000000, .octal);
3413 \\pub const MAY_NEED_PROMOTION_OCT = @import("std").meta.promoteIntLiteral(c_int, 0o20000000000, .octal);
34143414 });
34153415}