diff options
| author | Thomas Cheng <thomascheng1998@googlemail.com> | 2022-05-21 09:31:28 +0100 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-05-23 11:57:30 +0300 |
| commit | 64de32b34127df819322b91bc7643a0eb392d499 (patch) | |
| tree | 304fd61dab096980a8f8508d3705e641eab4dda3 /src | |
| parent | b64a1d5abb9ab2b73226555e1b49ee77cf9c1555 (diff) | |
| download | zig-64de32b34127df819322b91bc7643a0eb392d499.tar.gz zig-64de32b34127df819322b91bc7643a0eb392d499.zip | |
Fix segfault in error note
Diffstat (limited to 'src')
| -rw-r--r-- | src/stage1/ir.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp index 62834e564d..52044e9dce 100644 --- a/src/stage1/ir.cpp +++ b/src/stage1/ir.cpp @@ -15500,7 +15500,7 @@ static Stage1AirInst *ir_analyze_struct_field_ptr(IrAnalyze *ira, Scope *scope, is_const, is_volatile, PtrLenSingle, field->align, (uint32_t)(ptr_bit_offset + field->bit_offset_in_host), (uint32_t)host_int_bytes_for_result_type, false); - + if (field == struct_type->data.structure.misaligned_field) { // If field is the last single misaligned field it will be represented as array // 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 if (type_is_invalid(store_ptr->value->type)) { if (instruction->result_loc->id == ResultLocIdReturn && (value->value->type->id == ZigTypeIdErrorUnion || value->value->type->id == ZigTypeIdErrorSet) && - ira->explicit_return_type->id != ZigTypeIdErrorUnion && ira->explicit_return_type->id != ZigTypeIdErrorSet) + ira->explicit_return_type->id != ZigTypeIdErrorUnion && ira->explicit_return_type->id != ZigTypeIdErrorSet && + // Only add error note if we have a node to attach it to + ira->explicit_return_type_source_node) { add_error_note(ira->codegen, ira->new_irb.exec->first_err_trace_msg, ira->explicit_return_type_source_node, buf_create_from_str("function cannot return an error")); |
