| author | |
| committer | |
| log | 2cd19c05d0f615071102a5f18bb4cc800e86c07f |
| tree | 6559883d96c65456ecc3207ab41bdb6e6b07d9b0 |
| parent | 0f3f96c85095876e7e6f3f00e60915ec41f63700 |
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 #21542 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, | ... | @@ -7871,17 +7871,6 @@ static void gen_global_var(CodeGen *g, ZigVar *var, LLVMValueRef init_val, |
| 7871 | // TODO ^^ make an actual global variable | 7871 | // TODO ^^ make an actual global variable |
| 7872 | } | 7872 | } |
| 7873 | 7873 | ||
| 7874 | static 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 | |||
| 7885 | static void set_global_tls(CodeGen *g, ZigVar *var, LLVMValueRef global_value) { | 7874 | static void set_global_tls(CodeGen *g, ZigVar *var, LLVMValueRef global_value) { |
| 7886 | bool is_extern = var->decl_node->data.variable_declaration.is_extern; | 7875 | bool is_extern = var->decl_node->data.variable_declaration.is_extern; |
| 7887 | bool is_export = var->decl_node->data.variable_declaration.is_export; | 7876 | bool is_export = var->decl_node->data.variable_declaration.is_export; |
| ... | @@ -8359,8 +8348,6 @@ static void zig_llvm_emit_output(CodeGen *g) { | ... | @@ -8359,8 +8348,6 @@ static void zig_llvm_emit_output(CodeGen *g) { |
| 8359 | exit(1); | 8348 | exit(1); |
| 8360 | } | 8349 | } |
| 8361 | 8350 | ||
| 8362 | validate_inline_fns(g); | ||
| 8363 | |||
| 8364 | if (g->emit_bin) { | 8351 | if (g->emit_bin) { |
| 8365 | g->link_objects.append(&g->o_file_output_path); | 8352 | g->link_objects.append(&g->o_file_output_path); |
| 8366 | if (g->bundle_compiler_rt && (g->out_type == OutTypeObj || (g->out_type == OutTypeLib && !g->is_dynamic))) { | 8353 | 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 { | ... | @@ -6151,32 +6151,33 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6151 | "tmp.zig:2:15: error: expected error union type, found '?i32'", | 6151 | "tmp.zig:2:15: error: expected error union type, found '?i32'", |
| 6152 | }); | 6152 | }); |
| 6153 | 6153 | ||
| 6154 | cases.add("inline fn calls itself indirectly", | 6154 | // TODO test this in stage2, but we won't even try in stage1 |
| 6155 | \\export fn foo() void { | 6155 | //cases.add("inline fn calls itself indirectly", |
| 6156 | \\ bar(); | 6156 | // \\export fn foo() void { |
| 6157 | \\} | 6157 | // \\ bar(); |
| 6158 | \\inline fn bar() void { | 6158 | // \\} |
| 6159 | \\ baz(); | 6159 | // \\inline fn bar() void { |
| 6160 | \\ quux(); | 6160 | // \\ baz(); |
| 6161 | \\} | 6161 | // \\ quux(); |
| 6162 | \\inline fn baz() void { | 6162 | // \\} |
| 6163 | \\ bar(); | 6163 | // \\inline fn baz() void { |
| 6164 | \\ quux(); | 6164 | // \\ bar(); |
| 6165 | \\} | 6165 | // \\ quux(); |
| 6166 | \\extern fn quux() void; | 6166 | // \\} |
| 6167 | , &[_][]const u8{ | 6167 | // \\extern fn quux() void; |
| 6168 | "tmp.zig:4:1: error: unable to inline function", | 6168 | //, &[_][]const u8{ |
| 6169 | }); | 6169 | // "tmp.zig:4:1: error: unable to inline function", |
| 6170 | 6170 | //}); | |
| 6171 | cases.add("save reference to inline function", | 6171 | |
| 6172 | \\export fn foo() void { | 6172 | //cases.add("save reference to inline function", |
| 6173 | \\ quux(@ptrToInt(bar)); | 6173 | // \\export fn foo() void { |
| 6174 | \\} | 6174 | // \\ quux(@ptrToInt(bar)); |
| 6175 | \\inline fn bar() void { } | 6175 | // \\} |
| 6176 | \\extern fn quux(usize) void; | 6176 | // \\inline fn bar() void { } |
| 6177 | , &[_][]const u8{ | 6177 | // \\extern fn quux(usize) void; |
| 6178 | "tmp.zig:4:1: error: unable to inline function", | 6178 | //, &[_][]const u8{ |
| 6179 | }); | 6179 | // "tmp.zig:4:1: error: unable to inline function", |
| 6180 | //}); | ||
| 6180 | 6181 | ||
| 6181 | cases.add("signed integer division", | 6182 | cases.add("signed integer division", |
| 6182 | \\export fn foo(a: i32, b: i32) i32 { | 6183 | \\export fn foo(a: i32, b: i32) i32 { |