authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-24 20:07:39-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-24 20:24:37-07:00
logab658e32bdfa234b6c33f0718cac7a23fbd4074f
tree40878d73c0a191559605b020d20921d316189f20
parent76311aebff0f76dba96f589438957a32c364a011

Sema: fix export with Internal linkage

The Export tables should only be populated with non-internal exports.

2 files changed, 14 insertions(+), 0 deletions(-)

src/Sema.zig+4
...@@ -4321,6 +4321,10 @@ pub fn analyzeExport(...@@ -4321,6 +4321,10 @@ pub fn analyzeExport(
4321 const Export = Module.Export;4321 const Export = Module.Export;
4322 const mod = sema.mod;4322 const mod = sema.mod;
43234323
4324 if (borrowed_options.linkage == .Internal) {
4325 return;
4326 }
4327
4324 try mod.ensureDeclAnalyzed(exported_decl_index);4328 try mod.ensureDeclAnalyzed(exported_decl_index);
4325 const exported_decl = mod.declPtr(exported_decl_index);4329 const exported_decl = mod.declPtr(exported_decl_index);
4326 // TODO run the same checks as we do for C ABI struct fields4330 // TODO run the same checks as we do for C ABI struct fields
test/behavior/export.zig+10
...@@ -45,3 +45,13 @@ test "exporting enum type and value" {...@@ -45,3 +45,13 @@ test "exporting enum type and value" {
45 };45 };
46 try expect(S.e == .two);46 try expect(S.e == .two);
47}47}
48
49test "exporting with internal linkage" {
50 const S = struct {
51 fn foo() callconv(.C) void {}
52 comptime {
53 @export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .Internal });
54 }
55 };
56 S.foo();
57}