llvm: correctly lower references to generic functions

Closes #13522
This commit is contained in:
Veikka Tuominen
2022-11-11 17:56:37 +02:00
parent e01ec96288
commit d42f4abb9d
2 changed files with 22 additions and 2 deletions

View File

@@ -489,3 +489,20 @@ test "ptrCast comptime known slice to C pointer" {
var p = @ptrCast([*c]const u8, s);
try std.testing.expectEqualStrings(s, std.mem.sliceTo(p, 0));
}
test "ptrToInt on a generic function" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64 and builtin.os.tag != .linux) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64 and builtin.os.tag != .linux) return error.SkipZigTest; // TODO
const S = struct {
fn generic(i: anytype) @TypeOf(i) {
return i;
}
fn doTheTest(a: anytype) !void {
try expect(@ptrToInt(a) != 0);
}
};
try S.doTheTest(&S.generic);
}