diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-03-19 10:54:20 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-03-19 10:54:20 -0400 |
| commit | f824658e136738ea75c8bb3b53d9a67b2c4402b7 (patch) | |
| tree | b4dfb95c0146e5d2c8f34110a550e98c2a766609 /src/ir.cpp | |
| parent | 61266d26212e89e97d285eb61416d625303704bc (diff) | |
| download | zig-f824658e136738ea75c8bb3b53d9a67b2c4402b7.tar.gz zig-f824658e136738ea75c8bb3b53d9a67b2c4402b7.zip | |
slicing sentinel-terminated slice without end
now results in a sentinel-terminated slice.
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 4800dd9109..e20111e21f 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -26249,6 +26249,7 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i end = nullptr; } + ZigValue *slice_sentinel_val = nullptr; ZigType *non_sentinel_slice_ptr_type; ZigType *elem_type; @@ -26299,6 +26300,7 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i } } else if (is_slice(array_type)) { ZigType *maybe_sentineled_slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry; + slice_sentinel_val = maybe_sentineled_slice_ptr_type->data.pointer.sentinel; non_sentinel_slice_ptr_type = adjust_ptr_sentinel(ira->codegen, maybe_sentineled_slice_ptr_type, nullptr); elem_type = non_sentinel_slice_ptr_type->data.pointer.child_type; } else { @@ -26376,6 +26378,8 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i PtrLenSingle, ptr_byte_alignment, 0, 0, false); goto done_with_return_type; } + } else if (array_sentinel == nullptr && end == nullptr) { + array_sentinel = slice_sentinel_val; } if (array_sentinel != nullptr) { // TODO deal with non-abi-alignment here |
