zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit cd36baf530d0c312884f485ed619438c1de91ef1 (tree)
parent 40480c7cdc84697219e8b2434772709ad948ed4d
Author: Andrew Kelley <superjoe30@gmail.com>
Date:   Fri, 24 Nov 2017 22:04:24 -0500

fix assertion failed when invalid type encountered

Diffstat:
Msrc/analyze.cpp | 2+-
Msrc/ir.cpp | 3+++
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/analyze.cpp b/src/analyze.cpp @@ -338,7 +338,7 @@ TypeTableEntry *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x) { TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type, bool is_const, bool is_volatile, uint32_t byte_alignment, uint32_t bit_offset, uint32_t unaligned_bit_count) { - assert(child_type->id != TypeTableEntryIdInvalid); + assert(!type_is_invalid(child_type)); TypeId type_id = {}; TypeTableEntry **parent_pointer = nullptr; diff --git a/src/ir.cpp b/src/ir.cpp @@ -7966,6 +7966,9 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio ConstExprValue *const_val = &const_instr->value; const_val->type = pointee_type; type_ensure_zero_bits_known(ira->codegen, type_entry); + if (type_is_invalid(type_entry)) { + return ira->codegen->invalid_instruction; + } const_val->data.x_type = get_pointer_to_type_extra(ira->codegen, type_entry, ptr_is_const, ptr_is_volatile, get_abi_alignment(ira->codegen, type_entry), 0, 0); return const_instr;