authorgravatar for evan@lagerdata.comEvan Haas <evan@lagerdata.com> 2024-07-30 16:47:10-07:00
committergravatar for evan@lagerdata.comEvan Haas <evan@lagerdata.com> 2024-07-31 09:35:07-07:00
log4300a9c417cb9344d65e74335c9ce09cbf9bfc17
tree0697d26c6b3ca58a3f52e2fd23a95247c1986136
parent5cc9e18277e1b166be0898255448f3c642759bbc
signaturebadge-check Signed by SSH key SHA256:cf2/TFgSxv2uRX26INvFSw25Prr1Dy9H8MiRXgLpok4

aro_translate_c: Make function decls public


3 files changed, 13 insertions(+), 12 deletions(-)

lib/compiler/aro_translate_c.zig+3-2
...@@ -297,7 +297,7 @@ fn transDecl(c: *Context, scope: *Scope, decl: NodeIndex) !void {...@@ -297,7 +297,7 @@ fn transDecl(c: *Context, scope: *Scope, decl: NodeIndex) !void {
297 .inline_fn_def,297 .inline_fn_def,
298 .inline_static_fn_def,298 .inline_static_fn_def,
299 => {299 => {
300 try transFnDecl(c, decl);300 try transFnDecl(c, decl, true);
301 },301 },
302302
303 .@"var",303 .@"var",
...@@ -476,7 +476,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_node: NodeIndex, field_nod...@@ -476,7 +476,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_node: NodeIndex, field_nod
476 }476 }
477}477}
478478
479fn transFnDecl(c: *Context, fn_decl: NodeIndex) Error!void {479fn transFnDecl(c: *Context, fn_decl: NodeIndex, is_pub: bool) Error!void {
480 const raw_ty = c.tree.nodes.items(.ty)[@intFromEnum(fn_decl)];480 const raw_ty = c.tree.nodes.items(.ty)[@intFromEnum(fn_decl)];
481 const fn_ty = raw_ty.canonicalize(.standard);481 const fn_ty = raw_ty.canonicalize(.standard);
482 const node_data = c.tree.nodes.items(.data)[@intFromEnum(fn_decl)];482 const node_data = c.tree.nodes.items(.data)[@intFromEnum(fn_decl)];
...@@ -501,6 +501,7 @@ fn transFnDecl(c: *Context, fn_decl: NodeIndex) Error!void {...@@ -501,6 +501,7 @@ fn transFnDecl(c: *Context, fn_decl: NodeIndex) Error!void {
501501
502 else => unreachable,502 else => unreachable,
503 },503 },
504 .is_pub = is_pub,
504 };505 };
505506
506 const proto_node = transFnType(c, &c.global_scope.base, raw_ty, fn_ty, fn_decl_loc, proto_ctx) catch |err| switch (err) {507 const proto_node = transFnType(c, &c.global_scope.base, raw_ty, fn_ty, fn_decl_loc, proto_ctx) catch |err| switch (err) {
test/cases/translate_c/function prototype with parenthesis.c created+10
...@@ -0,0 +1,10 @@
1void (f0) (void *L);
2void ((f1)) (void *L);
3void (((f2))) (void *L);
4
5// translate-c
6// c_frontend=clang,aro
7//
8// pub extern fn f0(L: ?*anyopaque) void;
9// pub extern fn f1(L: ?*anyopaque) void;
10// pub extern fn f2(L: ?*anyopaque) void;
test/translate_c.zig-10
...@@ -494,16 +494,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -494,16 +494,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
494 \\};494 \\};
495 });495 });
496496
497 cases.add("function prototype with parenthesis",
498 \\void (f0) (void *L);
499 \\void ((f1)) (void *L);
500 \\void (((f2))) (void *L);
501 , &[_][]const u8{
502 \\pub extern fn f0(L: ?*anyopaque) void;
503 \\pub extern fn f1(L: ?*anyopaque) void;
504 \\pub extern fn f2(L: ?*anyopaque) void;
505 });
506
507 cases.add("array initializer w/ typedef",497 cases.add("array initializer w/ typedef",
508 \\typedef unsigned char uuid_t[16];498 \\typedef unsigned char uuid_t[16];
509 \\static const uuid_t UUID_NULL __attribute__ ((unused)) = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};499 \\static const uuid_t UUID_NULL __attribute__ ((unused)) = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};