aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-11-24 22:04:24 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-11-24 22:04:24 -0500
commitcd36baf530d0c312884f485ed619438c1de91ef1 (patch)
treed4edc52c68f77f39fdd8adf545f61adfef2c39e0 /src
parent40480c7cdc84697219e8b2434772709ad948ed4d (diff)
downloadzig-cd36baf530d0c312884f485ed619438c1de91ef1.tar.gz
zig-cd36baf530d0c312884f485ed619438c1de91ef1.zip
fix assertion failed when invalid type encountered
Diffstat (limited to 'src')
-rw-r--r--src/analyze.cpp2
-rw-r--r--src/ir.cpp3
2 files changed, 4 insertions, 1 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 7a9df874d4..1c223c63f7 100644
--- 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
index c81de7fa7a..35e6b3f8c6 100644
--- 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;