| ... | ... | @@ -4049,7 +4049,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4049 | 4049 | if (lval == LValPtr) { |
| 4050 | 4050 | return ir_build_ref(irb, scope, node, value, false, false); |
| 4051 | 4051 | } else { |
| 4052 | | return value; |
| 4052 | return ir_expr_wrap(irb, scope, value, result_loc); |
| 4053 | 4053 | } |
| 4054 | 4054 | } |
| 4055 | 4055 | |
| ... | ... | @@ -4077,7 +4077,9 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4077 | 4077 | return ir_build_undeclared_identifier(irb, scope, node, variable_name); |
| 4078 | 4078 | } |
| 4079 | 4079 | |
| 4080 | | static IrInstruction *ir_gen_array_access(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) { |
| 4080 | static IrInstruction *ir_gen_array_access(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, |
| 4081 | ResultLoc *result_loc) |
| 4082 | { |
| 4081 | 4083 | assert(node->type == NodeTypeArrayAccessExpr); |
| 4082 | 4084 | |
| 4083 | 4085 | AstNode *array_ref_node = node->data.array_access_expr.array_ref_expr; |
| ... | ... | @@ -4095,7 +4097,8 @@ static IrInstruction *ir_gen_array_access(IrBuilder *irb, Scope *scope, AstNode |
| 4095 | 4097 | if (lval == LValPtr) |
| 4096 | 4098 | return ptr_instruction; |
| 4097 | 4099 | |
| 4098 | | return ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 4100 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 4101 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 4099 | 4102 | } |
| 4100 | 4103 | |
| 4101 | 4104 | static IrInstruction *ir_gen_field_access(IrBuilder *irb, Scope *scope, AstNode *node) { |
| ... | ... | @@ -4754,7 +4757,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4754 | 4757 | if (lval == LValPtr) |
| 4755 | 4758 | return ptr_instruction; |
| 4756 | 4759 | |
| 4757 | | return ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 4760 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 4761 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 4758 | 4762 | } |
| 4759 | 4763 | case BuiltinFnIdTypeInfo: |
| 4760 | 4764 | { |
| ... | ... | @@ -7772,7 +7776,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 7772 | 7776 | case NodeTypeForExpr: |
| 7773 | 7777 | return ir_lval_wrap(irb, scope, ir_gen_for_expr(irb, scope, node), lval, result_loc); |
| 7774 | 7778 | case NodeTypeArrayAccessExpr: |
| 7775 | | return ir_gen_array_access(irb, scope, node, lval); |
| 7779 | return ir_gen_array_access(irb, scope, node, lval, result_loc); |
| 7776 | 7780 | case NodeTypeReturnExpr: |
| 7777 | 7781 | return ir_gen_return(irb, scope, node, lval); |
| 7778 | 7782 | case NodeTypeFieldAccessExpr: |
| ... | ... | @@ -7783,7 +7787,8 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 7783 | 7787 | if (lval == LValPtr) |
| 7784 | 7788 | return ptr_instruction; |
| 7785 | 7789 | |
| 7786 | | return ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 7790 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 7791 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 7787 | 7792 | } |
| 7788 | 7793 | case NodeTypePtrDeref: { |
| 7789 | 7794 | AstNode *expr_node = node->data.ptr_deref_expr.target; |
| ... | ... | @@ -7807,7 +7812,8 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 7807 | 7812 | if (lval == LValPtr) |
| 7808 | 7813 | return unwrapped_ptr; |
| 7809 | 7814 | |
| 7810 | | return ir_build_load_ptr(irb, scope, node, unwrapped_ptr); |
| 7815 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, node, unwrapped_ptr); |
| 7816 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 7811 | 7817 | } |
| 7812 | 7818 | case NodeTypeBoolLiteral: |
| 7813 | 7819 | return ir_lval_wrap(irb, scope, ir_gen_bool_literal(irb, scope, node), lval, result_loc); |
| ... | ... | @@ -13876,6 +13882,8 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 13876 | 13882 | bool var_class_requires_const = false; |
| 13877 | 13883 | |
| 13878 | 13884 | IrInstruction *var_ptr = decl_var_instruction->ptr->child; |
| 13885 | // if this assertion trips there may be a missing ir_expr_wrap in pass1 IR generation. |
| 13886 | ir_assert(var_ptr != nullptr, &decl_var_instruction->base); |
| 13879 | 13887 | if (type_is_invalid(var_ptr->value.type)) { |
| 13880 | 13888 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 13881 | 13889 | return ira->codegen->invalid_instruction; |