blob: 595a8273f8a81a1a203b7e6a657e0c98430e35e7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
const std = @import("std");
const builtin = @import("builtin");
const S = struct {
f: ?*const fn () i32,
};
const s = S{ .f = &f };
fn f() i32 {
return 1234;
}
test "don't emit an LLVM global for a const function when it's in an optional in a struct" {
if (builtin.zig_backend == .stage1) return error.SkipZigTest; // stage1 has different function pointers
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
try std.testing.expect(s.f.?() == 1234);
}
|