From 0d2f2b79eaf844e6bcdb41fe61c7e1655df9b1a0 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 18 Dec 2016 01:54:27 -0500 Subject: IR: basic support for implicit casting to const pointer --- src/codegen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 7ed799611f..e486764db8 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -1677,6 +1677,7 @@ static LLVMValueRef ir_render_ref(CodeGen *g, IrExecutable *executable, IrInstru if (handle_is_ptr(instruction->value->type_entry)) { return value; } else { + assert(instruction->tmp_ptr); LLVMBuildStore(g->builder, value, instruction->tmp_ptr); return instruction->tmp_ptr; } @@ -2843,6 +2844,7 @@ static void do_code_gen(CodeGen *g) { for (size_t alloca_i = 0; alloca_i < fn_table_entry->alloca_list.length; alloca_i += 1) { IrInstruction *instruction = fn_table_entry->alloca_list.at(alloca_i); LLVMValueRef *slot; + TypeTableEntry *slot_type = instruction->type_entry; if (instruction->id == IrInstructionIdCast) { IrInstructionCast *cast_instruction = (IrInstructionCast *)instruction; slot = &cast_instruction->tmp_ptr; @@ -2876,7 +2878,7 @@ static void do_code_gen(CodeGen *g) { } else { zig_unreachable(); } - *slot = LLVMBuildAlloca(g->builder, instruction->type_entry->type_ref, ""); + *slot = LLVMBuildAlloca(g->builder, slot_type->type_ref, ""); } ImportTableEntry *import = get_scope_import(&fn_table_entry->fndef_scope->base); -- cgit v1.2.3