mirror of
https://github.com/ziglang/zig.git
synced 2025-12-29 01:23:17 +00:00
Sema: emit compile error for comptime or inline call of function pointer
This commit is contained in:
parent
d6b430b520
commit
17404f8e6e
@ -6446,7 +6446,12 @@ fn analyzeCall(
|
||||
.extern_fn => return sema.fail(block, call_src, "{s} call of extern function", .{
|
||||
@as([]const u8, if (is_comptime_call) "comptime" else "inline"),
|
||||
}),
|
||||
else => unreachable,
|
||||
else => {
|
||||
assert(callee_ty.isPtrAtRuntime());
|
||||
return sema.fail(block, call_src, "{s} call of function pointer", .{
|
||||
@as([]const u8, if (is_comptime_call) "comptime" else "inline"),
|
||||
});
|
||||
},
|
||||
};
|
||||
if (func_ty_info.is_var_args) {
|
||||
return sema.fail(block, call_src, "{s} call of variadic function", .{
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
export fn entry() void {
|
||||
const fn_ptr = @intToPtr(*align(1) fn () void, 0xffd2);
|
||||
comptime fn_ptr();
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:20: error: comptime call of function pointer
|
||||
Loading…
x
Reference in New Issue
Block a user