translate-c correct assumption about macros

This commit is contained in:
Vexu 2020-03-05 12:15:12 +02:00
parent 8088bdc6d5
commit e063854563
No known key found for this signature in database
GPG Key ID: 59AEB8936E16A6AC
2 changed files with 10 additions and 1 deletions

View File

@ -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().?;

View File

@ -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