authorgravatar for thomascheng1998@googlemail.comThomas Cheng <thomascheng1998@googlemail.com> 2022-05-21 09:31:28+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-05-23 11:57:30+03:00
log64de32b34127df819322b91bc7643a0eb392d499
tree304fd61dab096980a8f8508d3705e641eab4dda3
parentb64a1d5abb9ab2b73226555e1b49ee77cf9c1555

Fix segfault in error note


1 files changed, 4 insertions(+), 2 deletions(-)

src/stage1/ir.cpp+4-2
......@@ -15500,7 +15500,7 @@ static Stage1AirInst *ir_analyze_struct_field_ptr(IrAnalyze *ira, Scope *scope,
1550015500 is_const, is_volatile, PtrLenSingle, field->align,
1550115501 (uint32_t)(ptr_bit_offset + field->bit_offset_in_host),
1550215502 (uint32_t)host_int_bytes_for_result_type, false);
15503
15503
1550415504 if (field == struct_type->data.structure.misaligned_field) {
1550515505 // If field is the last single misaligned field it will be represented as array
1550615506 // of bytes in LLVM but get_pointer_to_type_extra will set its host_int_bytes to 0.
......@@ -24781,7 +24781,9 @@ static Stage1AirInst *ir_analyze_instruction_end_expr(IrAnalyze *ira, Stage1ZirI
2478124781 if (type_is_invalid(store_ptr->value->type)) {
2478224782 if (instruction->result_loc->id == ResultLocIdReturn &&
2478324783 (value->value->type->id == ZigTypeIdErrorUnion || value->value->type->id == ZigTypeIdErrorSet) &&
24784 ira->explicit_return_type->id != ZigTypeIdErrorUnion && ira->explicit_return_type->id != ZigTypeIdErrorSet)
24784 ira->explicit_return_type->id != ZigTypeIdErrorUnion && ira->explicit_return_type->id != ZigTypeIdErrorSet &&
24785 // Only add error note if we have a node to attach it to
24786 ira->explicit_return_type_source_node)
2478524787 {
2478624788 add_error_note(ira->codegen, ira->new_irb.exec->first_err_trace_msg,
2478724789 ira->explicit_return_type_source_node, buf_create_from_str("function cannot return an error"));