diff options
| author | Vexu <git@vexu.eu> | 2020-03-05 12:15:12 +0200 |
|---|---|---|
| committer | Vexu <git@vexu.eu> | 2020-03-05 12:23:32 +0200 |
| commit | e063854563eac4ece0402320492657807571c5df (patch) | |
| tree | ad7394bd68895ca3f6a9695ce29f78f7cb3d3e8e | |
| parent | 8088bdc6d5d751766b4b4df700b864b5a0397eb6 (diff) | |
| download | zig-e063854563eac4ece0402320492657807571c5df.tar.gz zig-e063854563eac4ece0402320492657807571c5df.zip | |
translate-c correct assumption about macros
| -rw-r--r-- | src-self-hosted/translate_c.zig | 2 | ||||
| -rw-r--r-- | test/translate_c.zig | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig index 279c9facd3..5262bad1c0 100644 --- a/src-self-hosted/translate_c.zig +++ b/src-self-hosted/translate_c.zig @@ -4874,7 +4874,7 @@ fn transPreprocessorEntities(c: *Context, unit: *ZigClangASTUnit) Error!void { var tok_it = tok_list.iterator(0); const first_tok = tok_it.next().?; - assert(first_tok.id == .Identifier and mem.eql(u8, slice[first_tok.start..first_tok.end], name)); + assert(mem.eql(u8, slice[first_tok.start..first_tok.end], name)); var macro_fn = false; const next = tok_it.peek().?; diff --git a/test/translate_c.zig b/test/translate_c.zig index ef57ec55d0..9fb4c3b10e 100644 --- a/test/translate_c.zig +++ b/test/translate_c.zig @@ -25,6 +25,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\} }); + cases.add("macro keyword define", + \\#define foo 1 + \\#define inline 2 + , &[_][]const u8{ + \\pub const foo = 1; + , + \\pub const @"inline" = 2; + }); + cases.add("macro line continuation", \\#define FOO -\ \\BAR |
