aro_translate_c: Make function decls public

This commit is contained in:
Evan Haas 2024-07-30 16:47:10 -07:00
parent 5cc9e18277
commit 4300a9c417
No known key found for this signature in database
3 changed files with 13 additions and 12 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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};