compiler: disallow callconv etc from depending on function parameters

Resolves: #22261
This commit is contained in:
mlugg
2024-12-18 04:01:38 +00:00
parent 242bb44695
commit 7408679234
10 changed files with 327 additions and 849 deletions

View File

@@ -937,9 +937,13 @@ fn testLinksection(b: *Build, opts: Options) *Step {
const obj = addObject(b, opts, .{ .name = "main", .zig_source_bytes =
\\export var test_global: u32 linksection("__DATA,__TestGlobal") = undefined;
\\export fn testFn() linksection("__TEXT,__TestFn") callconv(.C) void {
\\ testGenericFn("A");
\\ TestGenericFn("A").f();
\\}
\\fn TestGenericFn(comptime suffix: []const u8) type {
\\ return struct {
\\ fn f() linksection("__TEXT,__TestGenFn" ++ suffix) void {}
\\ };
\\}
\\fn testGenericFn(comptime suffix: []const u8) linksection("__TEXT,__TestGenFn" ++ suffix) void {}
});
const check = obj.checkObject();
@@ -950,7 +954,7 @@ fn testLinksection(b: *Build, opts: Options) *Step {
if (opts.optimize == .Debug) {
check.checkInSymtab();
check.checkContains("(__TEXT,__TestGenFnA) _main.testGenericFn__anon_");
check.checkContains("(__TEXT,__TestGenFnA) _main.TestGenericFn(");
}
test_step.dependOn(&check.step);