zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 6106cf44197393a3ffa6bab9da0757ee4cecd311 (tree)
parent 027e2a16734d5a1ac884474ed688ecea9a785e73
Author: SuperAuguste <auguste.rame@gmail.com>
Date:   Sun,  5 Apr 2020 19:06:43 -0400

fixes

Diffstat:
Msrc-self-hosted/translate_c.zig | 5+----
Mtest/translate_c.zig | 6++++++
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig @@ -5387,10 +5387,7 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, switch (tok.id) { .CharLiteral => { const first_tok = it.list.at(0); - if ( - (source[tok.start+1] == '\\' and tok.end - tok.start == 4) - or (source[tok.start+1] != '\\' and tok.end - tok.start == 3) - ) { + if (source[tok.start] != '\'' or source[tok.start + 1] == '\\' or tok.end - tok.start == 3) { const token = try appendToken(c, .CharLiteral, try zigifyEscapeSequences(c, source[tok.start..tok.end], source[first_tok.start..first_tok.end], source_loc)); const node = try c.a().create(ast.Node.CharLiteral); node.* = .{ diff --git a/test/translate_c.zig b/test/translate_c.zig @@ -2847,4 +2847,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub const FOO = "a" ++ ("b" ++ "c"); }); + + cases.add("multibyte character literals", + \\#define FOO 'abcd' + , &[_][]const u8{ + \\pub const FOO = 0x61626364; + }); }