authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-04 17:38:48-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-04 17:38:48-04:00
log869167fc6d1f672f2bb827404b0e704223edab41
tree422b9f8ca23c123789a8e2a37fc68fcda74f3918
parentcbb3f1d76c6a89acdb04cb628c349eee69dfacf5
signaturelock-open Commit is signed but in an unrecognized format.

compile error for @noInlineCall on an inline fn

closes #1133

2 files changed, 16 insertions(+), 0 deletions(-)

src/ir.cpp+5
...@@ -13644,6 +13644,11 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13644,6 +13644,11 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
13644 return ir_finish_anal(ira, result->value.type);13644 return ir_finish_anal(ira, result->value.type);
13645 }13645 }
1364613646
13647 if (fn_entry != nullptr && fn_entry->fn_inline == FnInlineAlways && fn_inline == FnInlineNever) {
13648 ir_add_error(ira, &call_instruction->base,
13649 buf_sprintf("no-inline call of inline function"));
13650 return ira->codegen->builtin_types.entry_invalid;
13651 }
1364713652
13648 IrInstruction *new_call_instruction = ir_build_call_from(&ira->new_irb, &call_instruction->base,13653 IrInstruction *new_call_instruction = ir_build_call_from(&ira->new_irb, &call_instruction->base,
13649 fn_entry, fn_ref, call_param_count, casted_args, false, fn_inline, false, nullptr, casted_new_stack);13654 fn_entry, fn_ref, call_param_count, casted_args, false, fn_inline, false, nullptr, casted_new_stack);
test/compile_errors.zig+11
...@@ -1,6 +1,17 @@...@@ -1,6 +1,17 @@
1const tests = @import("tests.zig");1const tests = @import("tests.zig");
22
3pub fn addCases(cases: *tests.CompileErrorContext) void {3pub fn addCases(cases: *tests.CompileErrorContext) void {
4 cases.add(
5 "@noInlineCall on an inline function",
6 \\inline fn foo() void {}
7 \\
8 \\export fn entry() void {
9 \\ @noInlineCall(foo);
10 \\}
11 ,
12 ".tmp_source.zig:4:5: error: no-inline call of inline function",
13 );
14
4 cases.add(15 cases.add(
5 "comptime continue inside runtime switch",16 "comptime continue inside runtime switch",
6 \\export fn entry() void {17 \\export fn entry() void {