mirror of
https://github.com/ziglang/zig.git
synced 2025-02-12 23:50:18 +00:00
aro_translate_c: Make function decls public
This commit is contained in:
parent
5cc9e18277
commit
4300a9c417
@ -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) {
|
||||
|
10
test/cases/translate_c/function prototype with parenthesis.c
Normal file
10
test/cases/translate_c/function prototype with parenthesis.c
Normal 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;
|
@ -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};
|
||||
|
Loading…
Reference in New Issue
Block a user