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(...@@ -8459,9 +8459,7 @@ fn zirFunc(
8459 inst: Zir.Inst.Index,8459 inst: Zir.Inst.Index,
8460 inferred_error_set: bool,8460 inferred_error_set: bool,
8461) CompileError!Air.Inst.Ref {8461) CompileError!Air.Inst.Ref {
8462 const tracy = trace(@src());8462 const mod = sema.mod;
8463 defer tracy.end();
8464
8465 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;8463 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
8466 const extra = sema.code.extraData(Zir.Inst.Func, inst_data.payload_index);8464 const extra = sema.code.extraData(Zir.Inst.Func, inst_data.payload_index);
8467 const target = sema.mod.getTarget();8465 const target = sema.mod.getTarget();
...@@ -8502,8 +8500,7 @@ fn zirFunc(...@@ -8502,8 +8500,7 @@ fn zirFunc(
8502 // If this instruction has a body it means it's the type of the `owner_decl`8500 // If this instruction has a body it means it's the type of the `owner_decl`
8503 // otherwise it's a function type without a `callconv` attribute and should8501 // otherwise it's a function type without a `callconv` attribute and should
8504 // never be `.C`.8502 // never be `.C`.
8505 // NOTE: revisit when doing #17178503 const cc: std.builtin.CallingConvention = if (has_body and mod.declPtr(block.src_decl).is_exported)
8506 const cc: std.builtin.CallingConvention = if (sema.owner_decl.is_exported and has_body)
8507 .C8504 .C
8508 else8505 else
8509 .Unspecified;8506 .Unspecified;