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

This commit is contained in:
Vexu 2020-08-09 16:26:18 +03:00
parent 20510d209b
commit dfcac3cd76
No known key found for this signature in database
GPG Key ID: 59AEB8936E16A6AC
2 changed files with 8 additions and 8 deletions

View File

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

View File

@ -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",