diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-04-17 19:28:33 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-04-17 19:28:33 -0400 |
| commit | 2e0b114fdce1a10b8433438d8e2251cf708a72ec (patch) | |
| tree | bde37363bf88c19995da326706fa0db191d523b2 /src | |
| parent | 216e14891ea5fa1a88804d9781ef779d448d1220 (diff) | |
| download | zig-2e0b114fdce1a10b8433438d8e2251cf708a72ec.tar.gz zig-2e0b114fdce1a10b8433438d8e2251cf708a72ec.zip | |
add compile error for intToPtr with a 0-bit ptr
See #323
Diffstat (limited to 'src')
| -rw-r--r-- | src/ir.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 2159e8472d..e22f96fba0 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -12473,6 +12473,13 @@ static TypeTableEntry *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstr return ira->codegen->builtin_types.entry_invalid; } + type_ensure_zero_bits_known(ira->codegen, dest_type); + if (!type_has_bits(dest_type)) { + ir_add_error(ira, dest_type_value, + buf_sprintf("type '%s' has 0 bits and cannot store information", buf_ptr(&dest_type->name))); + return ira->codegen->builtin_types.entry_invalid; + } + IrInstruction *target = instruction->target->other; if (type_is_invalid(target->value.type)) return ira->codegen->builtin_types.entry_invalid; |
