authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-08-09 16:26:18+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-08-11 12:24:45+03:00
logdfcac3cd76c899c412fa3b78946ebce4f42f2ae8
tree20d982e86db3fd1840bd551c570c1e8d66c741c0
parent20510d209be44590f390c370f9e477d84ab46454
signaturelock-open Commit is signed but in an unrecognized format.

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


2 files changed, 8 insertions(+), 8 deletions(-)

src-self-hosted/translate_c.zig+1-1
...@@ -4907,7 +4907,7 @@ fn finishTransFnProto(...@@ -4907,7 +4907,7 @@ fn finishTransFnProto(
4907 const pub_tok = if (is_pub) try appendToken(rp.c, .Keyword_pub, "pub") else null;4907 const pub_tok = if (is_pub) try appendToken(rp.c, .Keyword_pub, "pub") else null;
4908 const extern_export_inline_tok = if (is_export)4908 const extern_export_inline_tok = if (is_export)
4909 try appendToken(rp.c, .Keyword_export, "export")4909 try appendToken(rp.c, .Keyword_export, "export")
4910 else if (cc == .C and is_extern)4910 else if (is_extern)
4911 try appendToken(rp.c, .Keyword_extern, "extern")4911 try appendToken(rp.c, .Keyword_extern, "extern")
4912 else4912 else
4913 null;4913 null;
test/translate_c.zig+7-7
...@@ -1260,11 +1260,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1260,11 +1260,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1260 \\void __attribute__((cdecl)) foo4(float *a);1260 \\void __attribute__((cdecl)) foo4(float *a);
1261 \\void __attribute__((thiscall)) foo5(float *a);1261 \\void __attribute__((thiscall)) foo5(float *a);
1262 , &[_][]const u8{1262 , &[_][]const u8{
1263 \\pub fn foo1(a: [*c]f32) callconv(.Fastcall) void;1263 \\pub extern fn foo1(a: [*c]f32) callconv(.Fastcall) void;
1264 \\pub fn foo2(a: [*c]f32) callconv(.Stdcall) void;1264 \\pub extern fn foo2(a: [*c]f32) callconv(.Stdcall) void;
1265 \\pub fn foo3(a: [*c]f32) callconv(.Vectorcall) void;1265 \\pub extern fn foo3(a: [*c]f32) callconv(.Vectorcall) void;
1266 \\pub extern fn foo4(a: [*c]f32) void;1266 \\pub extern fn foo4(a: [*c]f32) void;
1267 \\pub fn foo5(a: [*c]f32) callconv(.Thiscall) void;1267 \\pub extern fn foo5(a: [*c]f32) callconv(.Thiscall) void;
1268 });1268 });
12691269
1270 cases.addWithTarget("Calling convention", CrossTarget.parse(.{1270 cases.addWithTarget("Calling convention", CrossTarget.parse(.{
...@@ -1274,8 +1274,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1274,8 +1274,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1274 \\void __attribute__((pcs("aapcs"))) foo1(float *a);1274 \\void __attribute__((pcs("aapcs"))) foo1(float *a);
1275 \\void __attribute__((pcs("aapcs-vfp"))) foo2(float *a);1275 \\void __attribute__((pcs("aapcs-vfp"))) foo2(float *a);
1276 , &[_][]const u8{1276 , &[_][]const u8{
1277 \\pub fn foo1(a: [*c]f32) callconv(.AAPCS) void;1277 \\pub extern fn foo1(a: [*c]f32) callconv(.AAPCS) void;
1278 \\pub fn foo2(a: [*c]f32) callconv(.AAPCSVFP) void;1278 \\pub extern fn foo2(a: [*c]f32) callconv(.AAPCSVFP) void;
1279 });1279 });
12801280
1281 cases.addWithTarget("Calling convention", CrossTarget.parse(.{1281 cases.addWithTarget("Calling convention", CrossTarget.parse(.{
...@@ -1284,7 +1284,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1284,7 +1284,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1284 }) catch unreachable,1284 }) catch unreachable,
1285 \\void __attribute__((aarch64_vector_pcs)) foo1(float *a);1285 \\void __attribute__((aarch64_vector_pcs)) foo1(float *a);
1286 , &[_][]const u8{1286 , &[_][]const u8{
1287 \\pub fn foo1(a: [*c]f32) callconv(.Vectorcall) void;1287 \\pub extern fn foo1(a: [*c]f32) callconv(.Vectorcall) void;
1288 });1288 });
12891289
1290 cases.add("Parameterless function prototypes",1290 cases.add("Parameterless function prototypes",