aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2020-12-26 13:01:58 +0200
committerVeikka Tuominen <git@vexu.eu>2020-12-26 13:02:17 +0200
commit50e8c3882a3f753fe504a82ebc0d853a1fa1e0ed (patch)
treed5ae1724c040279e040891d2b0ea0bb3101274a0 /src
parent641bf4c46eb2d5c1f3e95898ed74848a56e0d999 (diff)
downloadzig-50e8c3882a3f753fe504a82ebc0d853a1fa1e0ed.tar.gz
zig-50e8c3882a3f753fe504a82ebc0d853a1fa1e0ed.zip
translate-c: demote variadic functions to declarations
Diffstat (limited to 'src')
-rw-r--r--src/translate_c.zig8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/translate_c.zig b/src/translate_c.zig
index 5a4fe76615..1b2aa4b219 100644
--- a/src/translate_c.zig
+++ b/src/translate_c.zig
@@ -550,7 +550,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void {
const fn_decl_loc = fn_decl.getLocation();
const has_body = fn_decl.hasBody();
const storage_class = fn_decl.getStorageClass();
- const decl_ctx = FnDeclContext{
+ var decl_ctx = FnDeclContext{
.fn_name = fn_name,
.has_body = has_body,
.storage_class = storage_class,
@@ -584,6 +584,12 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void {
const proto_node = switch (fn_type.getTypeClass()) {
.FunctionProto => blk: {
const fn_proto_type = @ptrCast(*const clang.FunctionProtoType, fn_type);
+ if (has_body and fn_proto_type.isVariadic()) {
+ decl_ctx.has_body = false;
+ decl_ctx.storage_class = .Extern;
+ decl_ctx.is_export = false;
+ try emitWarning(c, fn_decl_loc, "TODO unable to translate variadic function, demoted to declaration", .{});
+ }
break :blk transFnProto(rp, fn_decl, fn_proto_type, fn_decl_loc, decl_ctx, true) catch |err| switch (err) {
error.UnsupportedType => {
return failDecl(c, fn_decl_loc, fn_name, "unable to resolve prototype of function", .{});