Skip to content

Commit dff1481

Browse files
committed
improve copy_const_val with regards to parent backrefs
1 parent eb6f25f commit dff1481

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/ir.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11401,8 +11401,12 @@ static void copy_const_val(ZigValue *dest, ZigValue *src) {
1140111401
dest->data.x_struct.fields = alloc_const_vals_ptrs(dest->type->data.structure.src_field_count);
1140211402
for (size_t i = 0; i < dest->type->data.structure.src_field_count; i += 1) {
1140311403
copy_const_val(dest->data.x_struct.fields[i], src->data.x_struct.fields[i]);
11404-
}
11405-
}
11404+
dest->data.x_struct.fields[i]->parent.id = ConstParentIdStruct;
11405+
dest->data.x_struct.fields[i]->parent.data.p_struct.struct_val = dest;
11406+
dest->data.x_struct.fields[i]->parent.data.p_struct.field_index = i;
11407+
}
11408+
}
11409+
dest->parent.id = ConstParentIdNone;
1140611410
}
1140711411

1140811412
static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr,
@@ -17672,7 +17676,6 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1767217676

1767317677
IrInstruction *new_instruction = ir_const(ira, &call_instruction->base, result->type);
1767417678
copy_const_val(new_instruction->value, result);
17675-
new_instruction->value->type = return_type;
1767617679
return ir_finish_anal(ira, new_instruction);
1767717680
}
1767817681

0 commit comments

Comments
 (0)