mirror of
https://github.com/ziglang/zig.git
synced 2025-12-08 15:23:14 +00:00
add compile error for calling naked function
This commit is contained in:
parent
2b5e0b66a2
commit
1c60f31450
@ -9837,6 +9837,15 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
|
|||||||
|
|
||||||
AstNode *fn_proto_node = fn_entry ? fn_entry->proto_node : nullptr;;
|
AstNode *fn_proto_node = fn_entry ? fn_entry->proto_node : nullptr;;
|
||||||
|
|
||||||
|
if (fn_type_id->cc == CallingConventionNaked) {
|
||||||
|
ErrorMsg *msg = ir_add_error(ira, fn_ref, buf_sprintf("unable to call function with naked calling convention"));
|
||||||
|
if (fn_proto_node) {
|
||||||
|
add_error_note(ira->codegen, msg, fn_proto_node, buf_sprintf("declared here"));
|
||||||
|
}
|
||||||
|
return ira->codegen->builtin_types.entry_invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (fn_type_id->is_var_args) {
|
if (fn_type_id->is_var_args) {
|
||||||
if (call_param_count < src_param_count) {
|
if (call_param_count < src_param_count) {
|
||||||
ErrorMsg *msg = ir_add_error_node(ira, source_node,
|
ErrorMsg *msg = ir_add_error_node(ira, source_node,
|
||||||
|
|||||||
@ -1,6 +1,16 @@
|
|||||||
const tests = @import("tests.zig");
|
const tests = @import("tests.zig");
|
||||||
|
|
||||||
pub fn addCases(cases: &tests.CompileErrorContext) void {
|
pub fn addCases(cases: &tests.CompileErrorContext) void {
|
||||||
|
cases.add("calling function with naked calling convention",
|
||||||
|
\\export fn entry() void {
|
||||||
|
\\ foo();
|
||||||
|
\\}
|
||||||
|
\\nakedcc fn foo() void { }
|
||||||
|
,
|
||||||
|
".tmp_source.zig:2:5: error: unable to call function with naked calling convention",
|
||||||
|
".tmp_source.zig:4:9: note: declared here");
|
||||||
|
|
||||||
|
|
||||||
cases.add("function with invalid return type",
|
cases.add("function with invalid return type",
|
||||||
\\export fn foo() boid {}
|
\\export fn foo() boid {}
|
||||||
, ".tmp_source.zig:1:17: error: use of undeclared identifier 'boid'");
|
, ".tmp_source.zig:1:17: error: use of undeclared identifier 'boid'");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user