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 {...@@ -4436,7 +4436,7 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!Node {
4436 switch (lit_bytes[1]) {4436 switch (lit_bytes[1]) {
4437 '0'...'7' => {4437 '0'...'7' => {
4438 // Octal4438 // 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..]});
4440 radix = "octal";4440 radix = "octal";
4441 },4441 },
4442 'X' => {4442 'X' => {
test/translate_c.zig+1-1
...@@ -3410,6 +3410,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -3410,6 +3410,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
3410 \\pub const MAY_NEED_PROMOTION_2 = @import("std").meta.promoteIntLiteral(c_long, 307230723072, .decimal);3410 \\pub const MAY_NEED_PROMOTION_2 = @import("std").meta.promoteIntLiteral(c_long, 307230723072, .decimal);
3411 \\pub const MAY_NEED_PROMOTION_3 = @import("std").meta.promoteIntLiteral(c_ulong, 819281928192, .decimal);3411 \\pub const MAY_NEED_PROMOTION_3 = @import("std").meta.promoteIntLiteral(c_ulong, 819281928192, .decimal);
3412 \\pub const MAY_NEED_PROMOTION_HEX = @import("std").meta.promoteIntLiteral(c_int, 0x80000000, .hexadecimal);3412 \\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);
3414 });3414 });
3415}3415}