aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-09-21 10:30:36 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-09-21 10:31:11 -0400
commit44f2ee101f244342ec7e4cd81bb21d9a0c23267b (patch)
treee3e1ea2c38df41bfb37fbeafe0cdc5fc02652437 /src
parent073f7ebb0e2168d04212fd855235c3543f86a2be (diff)
downloadzig-44f2ee101f244342ec7e4cd81bb21d9a0c23267b.tar.gz
zig-44f2ee101f244342ec7e4cd81bb21d9a0c23267b.zip
fix comptime slice of pointer to array
closes #1565
Diffstat (limited to 'src')
-rw-r--r--src/ir.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 5e8d3c3a5a..327c4f9398 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -19073,11 +19073,7 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice
return ira->codegen->builtin_types.entry_invalid;
}
} else {
- ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.pointer.child_type,
- array_type->data.pointer.is_const, array_type->data.pointer.is_volatile,
- PtrLenUnknown,
- array_type->data.pointer.explicit_alignment, 0, 0);
- return_type = get_slice_type(ira->codegen, slice_ptr_type);
+ return_type = get_slice_type(ira->codegen, array_type);
if (!end) {
ir_add_error(ira, &instruction->base, buf_sprintf("slice of pointer must include end value"));
return ira->codegen->builtin_types.entry_invalid;
@@ -19141,9 +19137,15 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice
case ConstPtrSpecialDiscard:
zig_unreachable();
case ConstPtrSpecialRef:
- array_val = nullptr;
- abs_offset = SIZE_MAX;
- rel_end = 1;
+ if (parent_ptr->data.x_ptr.data.ref.pointee->type->id == ZigTypeIdArray) {
+ array_val = parent_ptr->data.x_ptr.data.ref.pointee;
+ abs_offset = 0;
+ rel_end = array_val->type->data.array.len;
+ } else {
+ array_val = nullptr;
+ abs_offset = SIZE_MAX;
+ rel_end = 1;
+ }
break;
case ConstPtrSpecialBaseArray:
array_val = parent_ptr->data.x_ptr.data.base_array.array_val;