diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-03 00:04:12 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-03 00:04:12 -0400 |
| commit | 95636c7e5ff6ad0eeb768a2a0a1d7533b5872e20 (patch) | |
| tree | bface1d6e36b3830f0229efcaf73d20bc3480f05 /src/ir.cpp | |
| parent | 92f747435930bc4d54114e414b372c7eafe7cc02 (diff) | |
| download | zig-95636c7e5ff6ad0eeb768a2a0a1d7533b5872e20.tar.gz zig-95636c7e5ff6ad0eeb768a2a0a1d7533b5872e20.zip | |
ability to @ptrCast to *void
fixes #960
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 4e64b3e002..2c3fadfc2d 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -19757,6 +19757,8 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 } static TypeTableEntry *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) { + Error err; + IrInstruction *dest_type_value = instruction->dest_type->other; TypeTableEntry *dest_type = ir_resolve_type(ira, dest_type_value); if (type_is_invalid(dest_type)) @@ -19810,9 +19812,13 @@ static TypeTableEntry *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstruc instruction->base.source_node, nullptr, ptr); casted_ptr->value.type = dest_type; - // keep the bigger alignment, it can only help + // Keep the bigger alignment, it can only help- + // unless the target is zero bits. + if ((err = type_ensure_zero_bits_known(ira->codegen, dest_type))) + return ira->codegen->builtin_types.entry_invalid; + IrInstruction *result; - if (src_align_bytes > dest_align_bytes) { + if (src_align_bytes > dest_align_bytes && type_has_bits(dest_type)) { result = ir_align_cast(ira, casted_ptr, src_align_bytes, false); if (type_is_invalid(result->value.type)) return ira->codegen->builtin_types.entry_invalid; |
