| author | |
| committer | |
| log | 4300a9c417cb9344d65e74335c9ce09cbf9bfc17 |
| tree | 0697d26c6b3ca58a3f52e2fd23a95247c1986136 |
| parent | 5cc9e18277e1b166be0898255448f3c642759bbc |
| signature |
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 | 297 | .inline_fn_def, |
| 298 | 298 | .inline_static_fn_def, |
| 299 | 299 | => { |
| 300 | try transFnDecl(c, decl); | |
| 300 | try transFnDecl(c, decl, true); | |
| 301 | 301 | }, |
| 302 | 302 | |
| 303 | 303 | .@"var", |
| ... | ... | @@ -476,7 +476,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_node: NodeIndex, field_nod |
| 476 | 476 | } |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | fn transFnDecl(c: *Context, fn_decl: NodeIndex) Error!void { | |
| 479 | fn transFnDecl(c: *Context, fn_decl: NodeIndex, is_pub: bool) Error!void { | |
| 480 | 480 | const raw_ty = c.tree.nodes.items(.ty)[@intFromEnum(fn_decl)]; |
| 481 | 481 | const fn_ty = raw_ty.canonicalize(.standard); |
| 482 | 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 | 501 | |
| 502 | 502 | else => unreachable, |
| 503 | 503 | }, |
| 504 | .is_pub = is_pub, | |
| 504 | 505 | }; |
| 505 | 506 | |
| 506 | 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 @@ |
| 1 | void (f0) (void *L); | |
| 2 | void ((f1)) (void *L); | |
| 3 | void (((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 | 494 | \\}; |
| 495 | 495 | }); |
| 496 | 496 | |
| 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 | 497 | cases.add("array initializer w/ typedef", |
| 508 | 498 | \\typedef unsigned char uuid_t[16]; |
| 509 | 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}; |