zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit dfcac3cd76c899c412fa3b78946ebce4f42f2ae8 (tree)
parent 20510d209be44590f390c370f9e477d84ab46454
Author: Vexu <git@vexu.eu>
Date:   Sun,  9 Aug 2020 16:26:18 +0300

translate-c: always add extern token for functions without body

Diffstat:
Msrc-self-hosted/translate_c.zig | 2+-
Mtest/translate_c.zig | 14+++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig @@ -4907,7 +4907,7 @@ fn finishTransFnProto( const pub_tok = if (is_pub) try appendToken(rp.c, .Keyword_pub, "pub") else null; const extern_export_inline_tok = if (is_export) try appendToken(rp.c, .Keyword_export, "export") - else if (cc == .C and is_extern) + else if (is_extern) try appendToken(rp.c, .Keyword_extern, "extern") else null; diff --git a/test/translate_c.zig b/test/translate_c.zig @@ -1260,11 +1260,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\void __attribute__((cdecl)) foo4(float *a); \\void __attribute__((thiscall)) foo5(float *a); , &[_][]const u8{ - \\pub fn foo1(a: [*c]f32) callconv(.Fastcall) void; - \\pub fn foo2(a: [*c]f32) callconv(.Stdcall) void; - \\pub fn foo3(a: [*c]f32) callconv(.Vectorcall) void; + \\pub extern fn foo1(a: [*c]f32) callconv(.Fastcall) void; + \\pub extern fn foo2(a: [*c]f32) callconv(.Stdcall) void; + \\pub extern fn foo3(a: [*c]f32) callconv(.Vectorcall) void; \\pub extern fn foo4(a: [*c]f32) void; - \\pub fn foo5(a: [*c]f32) callconv(.Thiscall) void; + \\pub extern fn foo5(a: [*c]f32) callconv(.Thiscall) void; }); cases.addWithTarget("Calling convention", CrossTarget.parse(.{ @@ -1274,8 +1274,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\void __attribute__((pcs("aapcs"))) foo1(float *a); \\void __attribute__((pcs("aapcs-vfp"))) foo2(float *a); , &[_][]const u8{ - \\pub fn foo1(a: [*c]f32) callconv(.AAPCS) void; - \\pub fn foo2(a: [*c]f32) callconv(.AAPCSVFP) void; + \\pub extern fn foo1(a: [*c]f32) callconv(.AAPCS) void; + \\pub extern fn foo2(a: [*c]f32) callconv(.AAPCSVFP) void; }); cases.addWithTarget("Calling convention", CrossTarget.parse(.{ @@ -1284,7 +1284,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { }) catch unreachable, \\void __attribute__((aarch64_vector_pcs)) foo1(float *a); , &[_][]const u8{ - \\pub fn foo1(a: [*c]f32) callconv(.Vectorcall) void; + \\pub extern fn foo1(a: [*c]f32) callconv(.Vectorcall) void; }); cases.add("Parameterless function prototypes",