| author | |
| committer | |
| log | 39f43fea8d0f6aa1c69cb7c3209f57f5ce00b273 |
| tree | 29955e3bab27927cc678af3f88bdc38572265a15 |
| parent | be2bd5848a880765f4bc7e2363ef201a0930a04b |
2 files changed, 13 insertions(+), 1 deletions(-)
src/translate_c.zig+1-1| ... | @@ -5647,7 +5647,7 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!Node { | ... | @@ -5647,7 +5647,7 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!Node { |
| 5647 | switch (m.list[m.i].id) { | 5647 | switch (m.list[m.i].id) { |
| 5648 | .IntegerLiteral => |suffix| { | 5648 | .IntegerLiteral => |suffix| { |
| 5649 | var radix: []const u8 = "decimal"; | 5649 | var radix: []const u8 = "decimal"; |
| 5650 | if (lit_bytes.len > 2 and lit_bytes[0] == '0') { | 5650 | if (lit_bytes.len >= 2 and lit_bytes[0] == '0') { |
| 5651 | switch (lit_bytes[1]) { | 5651 | switch (lit_bytes[1]) { |
| 5652 | '0'...'7' => { | 5652 | '0'...'7' => { |
| 5653 | // Octal | 5653 | // Octal |
test/translate_c.zig+12| ... | @@ -3842,4 +3842,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3842,4 +3842,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3842 | , &[_][]const u8{ | 3842 | , &[_][]const u8{ |
| 3843 | \\pub const FOO = ""; | 3843 | \\pub const FOO = ""; |
| 3844 | }); | 3844 | }); |
| 3845 | |||
| 3846 | cases.add("leading zeroes", | ||
| 3847 | \\#define O_RDONLY 00 | ||
| 3848 | \\#define HELLO 000 | ||
| 3849 | \\#define ZERO 0 | ||
| 3850 | \\#define WORLD 00000123 | ||
| 3851 | , &[_][]const u8{ | ||
| 3852 | \\pub const O_RDONLY = @as(c_int, 0o0); | ||
| 3853 | \\pub const HELLO = @as(c_int, 0o00); | ||
| 3854 | \\pub const ZERO = @as(c_int, 0); | ||
| 3855 | \\pub const WORLD = @as(c_int, 0o0000123); | ||
| 3856 | }); | ||
| 3845 | } | 3857 | } |