authorgravatar for auguste.rame@gmail.comSuperAuguste <auguste.rame@gmail.com> 2020-04-05 19:06:43-04:00
committergravatar for auguste.rame@gmail.comSuperAuguste <auguste.rame@gmail.com> 2020-04-05 19:06:43-04:00
log6106cf44197393a3ffa6bab9da0757ee4cecd311
tree88ee69a0010b90a629adcd66fcda90c4025c973a
parent027e2a16734d5a1ac884474ed688ecea9a785e73

fixes


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

src-self-hosted/translate_c.zig+1-4
......@@ -5387,10 +5387,7 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,
53875387 switch (tok.id) {
53885388 .CharLiteral => {
53895389 const first_tok = it.list.at(0);
5390 if (
5391 (source[tok.start+1] == '\\' and tok.end - tok.start == 4)
5392 or (source[tok.start+1] != '\\' and tok.end - tok.start == 3)
5393 ) {
5390 if (source[tok.start] != '\'' or source[tok.start + 1] == '\\' or tok.end - tok.start == 3) {
53945391 const token = try appendToken(c, .CharLiteral, try zigifyEscapeSequences(c, source[tok.start..tok.end], source[first_tok.start..first_tok.end], source_loc));
53955392 const node = try c.a().create(ast.Node.CharLiteral);
53965393 node.* = .{
test/translate_c.zig+6
......@@ -2847,4 +2847,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
28472847 , &[_][]const u8{
28482848 \\pub const FOO = "a" ++ ("b" ++ "c");
28492849 });
2850
2851 cases.add("multibyte character literals",
2852 \\#define FOO 'abcd'
2853 , &[_][]const u8{
2854 \\pub const FOO = 0x61626364;
2855 });
28502856}