From 2cd19c05d0f615071102a5f18bb4cc800e86c07f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 15 Aug 2020 09:53:39 -0700 Subject: [PATCH] stage1: remove buggy "unable to inline function" compile error We still want this compile error but I'm giving up on implementing it correctly in stage1. It's been buggy and has false positives sometimes. I left the test cases there, but commented out, so that when we go through the stage1 compile error cases and get coverage for them in stage2 we can reactivate the test cases. closes #2154 --- src/codegen.cpp | 13 ----------- test/compile_errors.zig | 51 +++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 38 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index 6941eae466..1bd8d5b7bc 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -7871,17 +7871,6 @@ static void gen_global_var(CodeGen *g, ZigVar *var, LLVMValueRef init_val, // TODO ^^ make an actual global variable } -static void validate_inline_fns(CodeGen *g) { - for (size_t i = 0; i < g->inline_fns.length; i += 1) { - ZigFn *fn_entry = g->inline_fns.at(i); - LLVMValueRef fn_val = LLVMGetNamedFunction(g->module, fn_entry->llvm_name); - if (fn_val != nullptr) { - add_node_error(g, fn_entry->proto_node, buf_sprintf("unable to inline function")); - } - } - report_errors_and_maybe_exit(g); -} - static void set_global_tls(CodeGen *g, ZigVar *var, LLVMValueRef global_value) { bool is_extern = var->decl_node->data.variable_declaration.is_extern; bool is_export = var->decl_node->data.variable_declaration.is_export; @@ -8359,8 +8348,6 @@ static void zig_llvm_emit_output(CodeGen *g) { exit(1); } - validate_inline_fns(g); - if (g->emit_bin) { g->link_objects.append(&g->o_file_output_path); if (g->bundle_compiler_rt && (g->out_type == OutTypeObj || (g->out_type == OutTypeLib && !g->is_dynamic))) { diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 4adc538602..70a9c47998 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -6151,32 +6151,33 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { "tmp.zig:2:15: error: expected error union type, found '?i32'", }); - cases.add("inline fn calls itself indirectly", - \\export fn foo() void { - \\ bar(); - \\} - \\inline fn bar() void { - \\ baz(); - \\ quux(); - \\} - \\inline fn baz() void { - \\ bar(); - \\ quux(); - \\} - \\extern fn quux() void; - , &[_][]const u8{ - "tmp.zig:4:1: error: unable to inline function", - }); + // TODO test this in stage2, but we won't even try in stage1 + //cases.add("inline fn calls itself indirectly", + // \\export fn foo() void { + // \\ bar(); + // \\} + // \\inline fn bar() void { + // \\ baz(); + // \\ quux(); + // \\} + // \\inline fn baz() void { + // \\ bar(); + // \\ quux(); + // \\} + // \\extern fn quux() void; + //, &[_][]const u8{ + // "tmp.zig:4:1: error: unable to inline function", + //}); - cases.add("save reference to inline function", - \\export fn foo() void { - \\ quux(@ptrToInt(bar)); - \\} - \\inline fn bar() void { } - \\extern fn quux(usize) void; - , &[_][]const u8{ - "tmp.zig:4:1: error: unable to inline function", - }); + //cases.add("save reference to inline function", + // \\export fn foo() void { + // \\ quux(@ptrToInt(bar)); + // \\} + // \\inline fn bar() void { } + // \\extern fn quux(usize) void; + //, &[_][]const u8{ + // "tmp.zig:4:1: error: unable to inline function", + //}); cases.add("signed integer division", \\export fn foo(a: i32, b: i32) i32 {