diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-03-19 11:52:15 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-03-19 09:53:30 -0400 |
| commit | e3c92d05328d7b40927bed66e7c2500a7853cdc8 (patch) | |
| tree | 4e6a1b8e5ee17cf644288144bf66fe59f189c7b5 /src/analyze.cpp | |
| parent | 7a361751e563c131399050f339dc47edf3c32325 (diff) | |
| download | zig-e3c92d05328d7b40927bed66e7c2500a7853cdc8.tar.gz zig-e3c92d05328d7b40927bed66e7c2500a7853cdc8.zip | |
ir: More changes to sentinel-terminated const arrays
* Don't add an extra slot for the sentinel. Most of the code keeps using
the constant value from the type descriptor, let's harmonize all the
code dealing with sentinels.
* Properly write out sentinel values when reinterpreting pointers at
comptime.
* Allow the reading of the 0th element in a `[0:S]T` type.
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index fbd7d85ac1..9ba247012d 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -5806,18 +5806,13 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) { // The elements array cannot be left unpopulated ZigType *array_type = result->type; ZigType *elem_type = array_type->data.array.child_type; - ZigValue *sentinel_value = array_type->data.array.sentinel; - const size_t elem_count = array_type->data.array.len + (sentinel_value != nullptr); + const size_t elem_count = array_type->data.array.len; result->data.x_array.data.s_none.elements = g->pass1_arena->allocate<ZigValue>(elem_count); for (size_t i = 0; i < elem_count; i += 1) { ZigValue *elem_val = &result->data.x_array.data.s_none.elements[i]; copy_const_val(g, elem_val, get_the_one_possible_value(g, elem_type)); } - if (sentinel_value != nullptr) { - ZigValue *last_elem_val = &result->data.x_array.data.s_none.elements[elem_count - 1]; - copy_const_val(g, last_elem_val, sentinel_value); - } } else if (result->type->id == ZigTypeIdPointer) { result->data.x_ptr.special = ConstPtrSpecialRef; result->data.x_ptr.data.ref.pointee = get_the_one_possible_value(g, result->type->data.pointer.child_type); |
