authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-15 09:53:39-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-15 09:53:39-07:00
log2cd19c05d0f615071102a5f18bb4cc800e86c07f
tree6559883d96c65456ecc3207ab41bdb6e6b07d9b0
parent0f3f96c85095876e7e6f3f00e60915ec41f63700

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

2 files changed, 27 insertions(+), 39 deletions(-)

src/codegen.cpp-13
......@@ -7871,17 +7871,6 @@ static void gen_global_var(CodeGen *g, ZigVar *var, LLVMValueRef init_val,
78717871 // TODO ^^ make an actual global variable
78727872}
78737873
7874static void validate_inline_fns(CodeGen *g) {
7875 for (size_t i = 0; i < g->inline_fns.length; i += 1) {
7876 ZigFn *fn_entry = g->inline_fns.at(i);
7877 LLVMValueRef fn_val = LLVMGetNamedFunction(g->module, fn_entry->llvm_name);
7878 if (fn_val != nullptr) {
7879 add_node_error(g, fn_entry->proto_node, buf_sprintf("unable to inline function"));
7880 }
7881 }
7882 report_errors_and_maybe_exit(g);
7883}
7884
78857874static void set_global_tls(CodeGen *g, ZigVar *var, LLVMValueRef global_value) {
78867875 bool is_extern = var->decl_node->data.variable_declaration.is_extern;
78877876 bool is_export = var->decl_node->data.variable_declaration.is_export;
......@@ -8359,8 +8348,6 @@ static void zig_llvm_emit_output(CodeGen *g) {
83598348 exit(1);
83608349 }
83618350
8362 validate_inline_fns(g);
8363
83648351 if (g->emit_bin) {
83658352 g->link_objects.append(&g->o_file_output_path);
83668353 if (g->bundle_compiler_rt && (g->out_type == OutTypeObj || (g->out_type == OutTypeLib && !g->is_dynamic))) {
test/compile_errors.zig+27-26
......@@ -6151,32 +6151,33 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
61516151 "tmp.zig:2:15: error: expected error union type, found '?i32'",
61526152 });
61536153
6154 cases.add("inline fn calls itself indirectly",
6155 \\export fn foo() void {
6156 \\ bar();
6157 \\}
6158 \\inline fn bar() void {
6159 \\ baz();
6160 \\ quux();
6161 \\}
6162 \\inline fn baz() void {
6163 \\ bar();
6164 \\ quux();
6165 \\}
6166 \\extern fn quux() void;
6167 , &[_][]const u8{
6168 "tmp.zig:4:1: error: unable to inline function",
6169 });
6170
6171 cases.add("save reference to inline function",
6172 \\export fn foo() void {
6173 \\ quux(@ptrToInt(bar));
6174 \\}
6175 \\inline fn bar() void { }
6176 \\extern fn quux(usize) void;
6177 , &[_][]const u8{
6178 "tmp.zig:4:1: error: unable to inline function",
6179 });
6154 // TODO test this in stage2, but we won't even try in stage1
6155 //cases.add("inline fn calls itself indirectly",
6156 // \\export fn foo() void {
6157 // \\ bar();
6158 // \\}
6159 // \\inline fn bar() void {
6160 // \\ baz();
6161 // \\ quux();
6162 // \\}
6163 // \\inline fn baz() void {
6164 // \\ bar();
6165 // \\ quux();
6166 // \\}
6167 // \\extern fn quux() void;
6168 //, &[_][]const u8{
6169 // "tmp.zig:4:1: error: unable to inline function",
6170 //});
6171
6172 //cases.add("save reference to inline function",
6173 // \\export fn foo() void {
6174 // \\ quux(@ptrToInt(bar));
6175 // \\}
6176 // \\inline fn bar() void { }
6177 // \\extern fn quux(usize) void;
6178 //, &[_][]const u8{
6179 // "tmp.zig:4:1: error: unable to inline function",
6180 //});
61806181
61816182 cases.add("signed integer division",
61826183 \\export fn foo(a: i32, b: i32) i32 {