| ... | ... | @@ -4607,6 +4607,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi |
| 4607 | 4607 | DeclAdapter{ .mod = mod }, |
| 4608 | 4608 | Namespace.DeclContext{ .module = mod }, |
| 4609 | 4609 | ); |
| 4610 | const comp = mod.comp; |
| 4610 | 4611 | if (!gop.found_existing) { |
| 4611 | 4612 | const new_decl_index = try mod.allocateNewDecl(namespace, decl_node, iter.parent_decl.src_scope); |
| 4612 | 4613 | const new_decl = mod.declPtr(new_decl_index); |
| ... | ... | @@ -4625,7 +4626,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi |
| 4625 | 4626 | 1 => blk: { |
| 4626 | 4627 | // test decl with no name. Skip the part where we check against |
| 4627 | 4628 | // the test name filter. |
| 4628 | | if (!mod.comp.bin_file.options.is_test) break :blk false; |
| 4629 | if (!comp.bin_file.options.is_test) break :blk false; |
| 4629 | 4630 | if (decl_pkg != mod.main_pkg) { |
| 4630 | 4631 | if (!mod.main_pkg_in_std) break :blk false; |
| 4631 | 4632 | const std_pkg = mod.main_pkg.table.get("std").?; |
| ... | ... | @@ -4636,19 +4637,23 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi |
| 4636 | 4637 | }, |
| 4637 | 4638 | else => blk: { |
| 4638 | 4639 | if (!is_named_test) break :blk false; |
| 4639 | | if (!mod.comp.bin_file.options.is_test) break :blk false; |
| 4640 | if (!comp.bin_file.options.is_test) break :blk false; |
| 4640 | 4641 | if (decl_pkg != mod.main_pkg) { |
| 4641 | 4642 | if (!mod.main_pkg_in_std) break :blk false; |
| 4642 | 4643 | const std_pkg = mod.main_pkg.table.get("std").?; |
| 4643 | 4644 | if (std_pkg != decl_pkg) break :blk false; |
| 4644 | 4645 | } |
| 4645 | | // TODO check the name against --test-filter |
| 4646 | if (comp.test_filter) |test_filter| { |
| 4647 | if (mem.indexOf(u8, decl_name, test_filter) == null) { |
| 4648 | break :blk false; |
| 4649 | } |
| 4650 | } |
| 4646 | 4651 | try mod.test_functions.put(gpa, new_decl_index, {}); |
| 4647 | 4652 | break :blk true; |
| 4648 | 4653 | }, |
| 4649 | 4654 | }; |
| 4650 | 4655 | if (want_analysis) { |
| 4651 | | mod.comp.work_queue.writeItemAssumeCapacity(.{ .analyze_decl = new_decl_index }); |
| 4656 | comp.work_queue.writeItemAssumeCapacity(.{ .analyze_decl = new_decl_index }); |
| 4652 | 4657 | } |
| 4653 | 4658 | new_decl.is_pub = is_pub; |
| 4654 | 4659 | new_decl.is_exported = is_exported; |
| ... | ... | @@ -4675,24 +4680,24 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!voi |
| 4675 | 4680 | decl.has_linksection_or_addrspace = has_linksection_or_addrspace; |
| 4676 | 4681 | decl.zir_decl_index = @intCast(u32, decl_sub_index); |
| 4677 | 4682 | if (decl.getFunction()) |_| { |
| 4678 | | switch (mod.comp.bin_file.tag) { |
| 4683 | switch (comp.bin_file.tag) { |
| 4679 | 4684 | .coff => { |
| 4680 | 4685 | // TODO Implement for COFF |
| 4681 | 4686 | }, |
| 4682 | 4687 | .elf => if (decl.fn_link.elf.len != 0) { |
| 4683 | 4688 | // TODO Look into detecting when this would be unnecessary by storing enough state |
| 4684 | 4689 | // in `Decl` to notice that the line number did not change. |
| 4685 | | mod.comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl_index }); |
| 4690 | comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl_index }); |
| 4686 | 4691 | }, |
| 4687 | 4692 | .macho => if (decl.fn_link.macho.len != 0) { |
| 4688 | 4693 | // TODO Look into detecting when this would be unnecessary by storing enough state |
| 4689 | 4694 | // in `Decl` to notice that the line number did not change. |
| 4690 | | mod.comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl_index }); |
| 4695 | comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl_index }); |
| 4691 | 4696 | }, |
| 4692 | 4697 | .plan9 => { |
| 4693 | 4698 | // TODO Look into detecting when this would be unnecessary by storing enough state |
| 4694 | 4699 | // in `Decl` to notice that the line number did not change. |
| 4695 | | mod.comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl_index }); |
| 4700 | comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl_index }); |
| 4696 | 4701 | }, |
| 4697 | 4702 | .c, .wasm, .spirv, .nvptx => {}, |
| 4698 | 4703 | } |