diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-12-26 17:11:36 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-12-26 17:11:36 -0500 |
| commit | 15f843e70f18fe0cd7ee31a67af6eb8d6302dcbc (patch) | |
| tree | 1d6e98c5c8849690d7ea9e75960f9d0c3814240a /src | |
| parent | 66a83d87383cd8de62898171b6665cb1d70af231 (diff) | |
| download | zig-15f843e70f18fe0cd7ee31a67af6eb8d6302dcbc.tar.gz zig-15f843e70f18fe0cd7ee31a67af6eb8d6302dcbc.zip | |
IR: pass castSliceToU8Slice test
Diffstat (limited to 'src')
| -rw-r--r-- | src/ir.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index d58c813f3e..8f31bf3b45 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -5220,10 +5220,18 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s source_instr->source_node, ira->codegen->builtin_types.entry_usize, false); init_const_usize(ira->codegen, &end->value, array_type->data.array.len); + bool is_const; + if (array->id == IrInstructionIdLoadPtr) { + IrInstructionLoadPtr *load_ptr_inst = (IrInstructionLoadPtr *) array; + is_const = load_ptr_inst->ptr->value.type->data.pointer.is_const; + } else { + is_const = true; + } + IrInstruction *result = ir_build_slice(&ira->new_irb, source_instr->scope, - source_instr->source_node, array, start, end, true, false); + source_instr->source_node, array, start, end, is_const, false); TypeTableEntry *child_type = array_type->data.array.child_type; - result->value.type = get_slice_type(ira->codegen, child_type, true); + result->value.type = get_slice_type(ira->codegen, child_type, is_const); ir_add_alloca(ira, result, result->value.type); return result; } |
