| ... | @@ -2671,6 +2671,9 @@ fn varDecl( | ... | @@ -2671,6 +2671,9 @@ fn varDecl( |
| 2671 | return &sub_scope.base; | 2671 | return &sub_scope.base; |
| 2672 | } | 2672 | } |
| 2673 | | 2673 | |
| | 2674 | const is_comptime = gz.force_comptime or |
| | 2675 | tree.nodes.items(.tag)[var_decl.ast.init_node] == .@"comptime"; |
| | 2676 | |
| 2674 | // Detect whether the initialization expression actually uses the | 2677 | // Detect whether the initialization expression actually uses the |
| 2675 | // result location pointer. | 2678 | // result location pointer. |
| 2676 | var init_scope = gz.makeSubBlock(scope); | 2679 | var init_scope = gz.makeSubBlock(scope); |
| ... | @@ -2692,7 +2695,7 @@ fn varDecl( | ... | @@ -2692,7 +2695,7 @@ fn varDecl( |
| 2692 | .type_inst = type_inst, | 2695 | .type_inst = type_inst, |
| 2693 | .align_inst = align_inst, | 2696 | .align_inst = align_inst, |
| 2694 | .is_const = true, | 2697 | .is_const = true, |
| 2695 | .is_comptime = gz.force_comptime, | 2698 | .is_comptime = is_comptime, |
| 2696 | }); | 2699 | }); |
| 2697 | init_scope.instructions_top = gz.instructions.items.len; | 2700 | init_scope.instructions_top = gz.instructions.items.len; |
| 2698 | } | 2701 | } |
| ... | @@ -2700,7 +2703,7 @@ fn varDecl( | ... | @@ -2700,7 +2703,7 @@ fn varDecl( |
| 2700 | } else { | 2703 | } else { |
| 2701 | const alloc = if (align_inst == .none) alloc: { | 2704 | const alloc = if (align_inst == .none) alloc: { |
| 2702 | init_scope.instructions_top = gz.instructions.items.len; | 2705 | init_scope.instructions_top = gz.instructions.items.len; |
| 2703 | const tag: Zir.Inst.Tag = if (gz.force_comptime) | 2706 | const tag: Zir.Inst.Tag = if (is_comptime) |
| 2704 | .alloc_inferred_comptime | 2707 | .alloc_inferred_comptime |
| 2705 | else | 2708 | else |
| 2706 | .alloc_inferred; | 2709 | .alloc_inferred; |
| ... | @@ -2711,7 +2714,7 @@ fn varDecl( | ... | @@ -2711,7 +2714,7 @@ fn varDecl( |
| 2711 | .type_inst = .none, | 2714 | .type_inst = .none, |
| 2712 | .align_inst = align_inst, | 2715 | .align_inst = align_inst, |
| 2713 | .is_const = true, | 2716 | .is_const = true, |
| 2714 | .is_comptime = gz.force_comptime, | 2717 | .is_comptime = is_comptime, |
| 2715 | }); | 2718 | }); |
| 2716 | init_scope.instructions_top = gz.instructions.items.len; | 2719 | init_scope.instructions_top = gz.instructions.items.len; |
| 2717 | break :alloc ref; | 2720 | break :alloc ref; |