diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-04-23 09:55:06 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-04-24 15:55:32 -0400 |
| commit | a7a8c433d0153bf8d71d17f2cf54027ba8eff805 (patch) | |
| tree | 7337f6fe1320661e291930515061b2c11cdea6b2 /src/ir.cpp | |
| parent | 7634e67ba503fdbdf75daff48a13f9d35e331cd4 (diff) | |
| download | zig-a7a8c433d0153bf8d71d17f2cf54027ba8eff805.tar.gz zig-a7a8c433d0153bf8d71d17f2cf54027ba8eff805.zip | |
stage1: Prevent the creation of illegal ptr types
Closes #5140
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 5c8d8157d2..78d5ae2ff9 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -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; |
