stage1: Prevent the creation of illegal ptr types

Closes #5140
This commit is contained in:
LemonBoy
2020-04-23 09:55:06 +02:00
committed by Andrew Kelley
parent 7634e67ba5
commit a7a8c433d0
2 changed files with 14 additions and 0 deletions

View File

@@ -29079,6 +29079,12 @@ static IrInstGen *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstSrcPtrTy
lazy_ptr_type->base.id = LazyValueIdPtrType;
if (instruction->sentinel != nullptr) {
if (instruction->ptr_len != PtrLenUnknown) {
ir_add_error(ira, &instruction->base.base,
buf_sprintf("sentinels are only allowed on unknown-length pointers"));
return ira->codegen->invalid_inst_gen;
}
lazy_ptr_type->sentinel = instruction->sentinel->child;
if (ir_resolve_const(ira, lazy_ptr_type->sentinel, LazyOk) == nullptr)
return ira->codegen->invalid_inst_gen;