diff --git a/lib/compiler/aro_translate_c.zig b/lib/compiler/aro_translate_c.zig index 5c9e9771ba..dd8ca54819 100644 --- a/lib/compiler/aro_translate_c.zig +++ b/lib/compiler/aro_translate_c.zig @@ -297,7 +297,7 @@ fn transDecl(c: *Context, scope: *Scope, decl: NodeIndex) !void { .inline_fn_def, .inline_static_fn_def, => { - try transFnDecl(c, decl); + try transFnDecl(c, decl, true); }, .@"var", @@ -476,7 +476,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_node: NodeIndex, field_nod } } -fn transFnDecl(c: *Context, fn_decl: NodeIndex) Error!void { +fn transFnDecl(c: *Context, fn_decl: NodeIndex, is_pub: bool) Error!void { const raw_ty = c.tree.nodes.items(.ty)[@intFromEnum(fn_decl)]; const fn_ty = raw_ty.canonicalize(.standard); const node_data = c.tree.nodes.items(.data)[@intFromEnum(fn_decl)]; @@ -501,6 +501,7 @@ fn transFnDecl(c: *Context, fn_decl: NodeIndex) Error!void { else => unreachable, }, + .is_pub = is_pub, }; const proto_node = transFnType(c, &c.global_scope.base, raw_ty, fn_ty, fn_decl_loc, proto_ctx) catch |err| switch (err) { diff --git a/test/cases/translate_c/function prototype with parenthesis.c b/test/cases/translate_c/function prototype with parenthesis.c new file mode 100644 index 0000000000..7b93e3fa93 --- /dev/null +++ b/test/cases/translate_c/function prototype with parenthesis.c @@ -0,0 +1,10 @@ +void (f0) (void *L); +void ((f1)) (void *L); +void (((f2))) (void *L); + +// translate-c +// c_frontend=clang,aro +// +// pub extern fn f0(L: ?*anyopaque) void; +// pub extern fn f1(L: ?*anyopaque) void; +// pub extern fn f2(L: ?*anyopaque) void; diff --git a/test/translate_c.zig b/test/translate_c.zig index c07b29f772..31bb577f00 100644 --- a/test/translate_c.zig +++ b/test/translate_c.zig @@ -494,16 +494,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\}; }); - cases.add("function prototype with parenthesis", - \\void (f0) (void *L); - \\void ((f1)) (void *L); - \\void (((f2))) (void *L); - , &[_][]const u8{ - \\pub extern fn f0(L: ?*anyopaque) void; - \\pub extern fn f1(L: ?*anyopaque) void; - \\pub extern fn f2(L: ?*anyopaque) void; - }); - cases.add("array initializer w/ typedef", \\typedef unsigned char uuid_t[16]; \\static const uuid_t UUID_NULL __attribute__ ((unused)) = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};