authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-18 12:37:20-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-18 19:02:06-07:00
logabe71b40c54c98badd4b18328ae22c8425add4b3
treef28b1a155583bf065a6074c18d65c99cd8ca3798
parent3f2a4720b1ef057215c8240b3a377c523ee63e94

Sema: use src_decl for exported status

Fixes wrong calling convention in instantiated functions.

1 files changed, 2 insertions(+), 5 deletions(-)

src/Sema.zig+2-5
......@@ -8459,9 +8459,7 @@ fn zirFunc(
84598459 inst: Zir.Inst.Index,
84608460 inferred_error_set: bool,
84618461) CompileError!Air.Inst.Ref {
8462 const tracy = trace(@src());
8463 defer tracy.end();
8464
8462 const mod = sema.mod;
84658463 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
84668464 const extra = sema.code.extraData(Zir.Inst.Func, inst_data.payload_index);
84678465 const target = sema.mod.getTarget();
......@@ -8502,8 +8500,7 @@ fn zirFunc(
85028500 // If this instruction has a body it means it's the type of the `owner_decl`
85038501 // otherwise it's a function type without a `callconv` attribute and should
85048502 // never be `.C`.
8505 // NOTE: revisit when doing #1717
8506 const cc: std.builtin.CallingConvention = if (sema.owner_decl.is_exported and has_body)
8503 const cc: std.builtin.CallingConvention = if (has_body and mod.declPtr(block.src_decl).is_exported)
85078504 .C
85088505 else
85098506 .Unspecified;