authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-02-13 09:09:49+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-13 12:21:28-05:00
logfa377dbd1510fc733607afe47dc04dfe55d5ff88
treec69eb6c3be0a1747768e7137bd26ad9e24a7e69e
parent1fb70497d24da9c0cb6f0e025948fa40eaaa36af

fix c tokenizer bug


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

lib/std/c/tokenizer.zig+4
......@@ -651,6 +651,7 @@ pub const Tokenizer = struct {
651651 state = .StringLiteral;
652652 },
653653 else => {
654 self.index -= 1;
654655 state = .Identifier;
655656 },
656657 },
......@@ -660,6 +661,7 @@ pub const Tokenizer = struct {
660661 state = .StringLiteral;
661662 },
662663 else => {
664 self.index -= 1;
663665 state = .Identifier;
664666 },
665667 },
......@@ -673,6 +675,7 @@ pub const Tokenizer = struct {
673675 state = .StringLiteral;
674676 },
675677 else => {
678 self.index -= 1;
676679 state = .Identifier;
677680 },
678681 },
......@@ -686,6 +689,7 @@ pub const Tokenizer = struct {
686689 state = .StringLiteral;
687690 },
688691 else => {
692 self.index -= 1;
689693 state = .Identifier;
690694 },
691695 },
test/translate_c.zig+5
......@@ -1362,12 +1362,17 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
13621362 cases.add("basic macro function",
13631363 \\extern int c;
13641364 \\#define BASIC(c) (c*2)
1365 \\#define FOO(L,b) (L + b)
13651366 , &[_][]const u8{
13661367 \\pub extern var c: c_int;
13671368 ,
13681369 \\pub inline fn BASIC(c_1: var) @TypeOf(c_1 * 2) {
13691370 \\ return c_1 * 2;
13701371 \\}
1372 ,
1373 \\pub inline fn FOO(L: var, b: var) @TypeOf(L + b) {
1374 \\ return L + b;
1375 \\}
13711376 });
13721377
13731378 cases.add("macro defines string literal with hex",