translate-c properly handle unused var-args
This commit is contained in:
parent
576320e6d5
commit
f35a963ac5
@ -477,8 +477,14 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void {
|
|||||||
var it = proto_node.params.iterator(0);
|
var it = proto_node.params.iterator(0);
|
||||||
while (it.next()) |p| {
|
while (it.next()) |p| {
|
||||||
const param = @fieldParentPtr(ast.Node.ParamDecl, "base", p.*);
|
const param = @fieldParentPtr(ast.Node.ParamDecl, "base", p.*);
|
||||||
const param_name = tokenSlice(c, param.name_token orelse
|
const param_name = if (param.name_token) |name_tok|
|
||||||
return failDecl(c, fn_decl_loc, fn_name, "function {} parameter has no name", .{fn_name}));
|
tokenSlice(c, name_tok)
|
||||||
|
else if (param.var_args_token != null) {
|
||||||
|
assert(it.next() == null);
|
||||||
|
_ = proto_node.params.pop();
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
return failDecl(c, fn_decl_loc, fn_name, "function {} parameter has no name", .{fn_name});
|
||||||
|
|
||||||
const mangled_param_name = try block_scope.makeMangledName(c, param_name);
|
const mangled_param_name = try block_scope.makeMangledName(c, param_name);
|
||||||
|
|
||||||
|
@ -2307,9 +2307,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
|||||||
\\inline void a(void) {}
|
\\inline void a(void) {}
|
||||||
\\static void b(void) {}
|
\\static void b(void) {}
|
||||||
\\void c(void) {}
|
\\void c(void) {}
|
||||||
|
\\static void foo() {}
|
||||||
, &[_][]const u8{
|
, &[_][]const u8{
|
||||||
\\pub fn a() void {}
|
\\pub fn a() void {}
|
||||||
\\pub fn b() void {}
|
\\pub fn b() void {}
|
||||||
\\pub export fn c() void {}
|
\\pub export fn c() void {}
|
||||||
|
\\pub fn foo() void {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user