From 2e6aa6d813cf3fd4180b8c9ffc671b4bcee54586 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 18 Dec 2016 13:55:34 -0500 Subject: IR: fix codegen of ref instruction --- src/ir.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index b215721acb..b920ee2f70 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4732,7 +4732,15 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_ IrInstructionLoadPtr *load_ptr_inst = (IrInstructionLoadPtr *)value; return load_ptr_inst->ptr; } else { - zig_panic("TODO more ways to cast to const pointer"); + IrInstruction *new_instruction = ir_build_ref(&ira->new_irb, source_instr->scope, source_instr->source_node, value); + + TypeTableEntry *child_type = wanted_type->data.pointer.child_type; + if (type_has_bits(child_type)) { + FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); + assert(fn_entry); + fn_entry->alloca_list.append(new_instruction); + } + return new_instruction; } } -- cgit v1.2.3