Merge pull request #7001 from Vexu/translate-c
Translate-c: fix macro functions with no arguments
This commit is contained in:
commit
a1a16a941e
@ -5437,9 +5437,8 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
|
||||
defer fn_params.deinit();
|
||||
|
||||
while (true) {
|
||||
if (m.next().? != .Identifier) {
|
||||
return m.fail(c, "unable to translate C expr: expected identifier", .{});
|
||||
}
|
||||
if (m.peek().? != .Identifier) break;
|
||||
_ = m.next();
|
||||
|
||||
const mangled_name = try block_scope.makeMangledName(c, m.slice());
|
||||
const param_name_tok = try appendIdentifier(c, mangled_name);
|
||||
@ -5459,8 +5458,7 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
|
||||
.param_type = .{ .any_type = &any_type.base },
|
||||
};
|
||||
|
||||
if (m.peek().? != .Comma)
|
||||
break;
|
||||
if (m.peek().? != .Comma) break;
|
||||
_ = m.next();
|
||||
_ = try appendToken(c, .Comma, ",");
|
||||
}
|
||||
|
@ -1589,6 +1589,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\extern int c;
|
||||
\\#define BASIC(c) (c*2)
|
||||
\\#define FOO(L,b) (L + b)
|
||||
\\#define BAR() (c*c)
|
||||
, &[_][]const u8{
|
||||
\\pub extern var c: c_int;
|
||||
,
|
||||
@ -1599,6 +1600,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\pub inline fn FOO(L: anytype, b: anytype) @TypeOf(L + b) {
|
||||
\\ return L + b;
|
||||
\\}
|
||||
,
|
||||
\\pub inline fn BAR() @TypeOf(c * c) {
|
||||
\\ return c * c;
|
||||
\\}
|
||||
});
|
||||
|
||||
cases.add("macro defines string literal with hex",
|
||||
|
Loading…
x
Reference in New Issue
Block a user