| ... | @@ -803,13 +803,7 @@ ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size, Zi | ... | @@ -803,13 +803,7 @@ ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size, Zi |
| 803 | } | 803 | } |
| 804 | buf_appendf(&entry->name, "]%s", buf_ptr(&child_type->name)); | 804 | buf_appendf(&entry->name, "]%s", buf_ptr(&child_type->name)); |
| 805 | | 805 | |
| 806 | size_t full_array_size; | 806 | size_t full_array_size = array_size + ((sentinel != nullptr) ? 1 : 0); |
| 807 | if (array_size == 0) { | | |
| 808 | full_array_size = 0; | | |
| 809 | } else { | | |
| 810 | full_array_size = array_size + ((sentinel != nullptr) ? 1 : 0); | | |
| 811 | } | | |
| 812 | | | |
| 813 | entry->size_in_bits = child_type->size_in_bits * full_array_size; | 807 | entry->size_in_bits = child_type->size_in_bits * full_array_size; |
| 814 | entry->abi_align = child_type->abi_align; | 808 | entry->abi_align = child_type->abi_align; |
| 815 | entry->abi_size = child_type->abi_size * full_array_size; | 809 | entry->abi_size = child_type->abi_size * full_array_size; |
| ... | @@ -1197,7 +1191,8 @@ Error type_val_resolve_zero_bits(CodeGen *g, ZigValue *type_val, ZigType *parent | ... | @@ -1197,7 +1191,8 @@ Error type_val_resolve_zero_bits(CodeGen *g, ZigValue *type_val, ZigType *parent |
| 1197 | LazyValueArrayType *lazy_array_type = | 1191 | LazyValueArrayType *lazy_array_type = |
| 1198 | reinterpret_cast<LazyValueArrayType *>(type_val->data.x_lazy); | 1192 | reinterpret_cast<LazyValueArrayType *>(type_val->data.x_lazy); |
| 1199 | | 1193 | |
| 1200 | if (lazy_array_type->length < 1) { | 1194 | // The sentinel counts as an extra element |
| | 1195 | if (lazy_array_type->length == 0 && lazy_array_type->sentinel == nullptr) { |
| 1201 | *is_zero_bits = true; | 1196 | *is_zero_bits = true; |
| 1202 | return ErrorNone; | 1197 | return ErrorNone; |
| 1203 | } | 1198 | } |
| ... | @@ -1452,7 +1447,8 @@ static OnePossibleValue type_val_resolve_has_one_possible_value(CodeGen *g, ZigV | ... | @@ -1452,7 +1447,8 @@ static OnePossibleValue type_val_resolve_has_one_possible_value(CodeGen *g, ZigV |
| 1452 | case LazyValueIdArrayType: { | 1447 | case LazyValueIdArrayType: { |
| 1453 | LazyValueArrayType *lazy_array_type = | 1448 | LazyValueArrayType *lazy_array_type = |
| 1454 | reinterpret_cast<LazyValueArrayType *>(type_val->data.x_lazy); | 1449 | reinterpret_cast<LazyValueArrayType *>(type_val->data.x_lazy); |
| 1455 | if (lazy_array_type->length < 1) | 1450 | // The sentinel counts as an extra element |
| | 1451 | if (lazy_array_type->length == 0 && lazy_array_type->sentinel == nullptr) |
| 1456 | return OnePossibleValueYes; | 1452 | return OnePossibleValueYes; |
| 1457 | return type_val_resolve_has_one_possible_value(g, lazy_array_type->elem_type->value); | 1453 | return type_val_resolve_has_one_possible_value(g, lazy_array_type->elem_type->value); |
| 1458 | } | 1454 | } |
| ... | @@ -5739,7 +5735,8 @@ OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry) { | ... | @@ -5739,7 +5735,8 @@ OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry) { |
| 5739 | case ZigTypeIdUnreachable: | 5735 | case ZigTypeIdUnreachable: |
| 5740 | return OnePossibleValueYes; | 5736 | return OnePossibleValueYes; |
| 5741 | case ZigTypeIdArray: | 5737 | case ZigTypeIdArray: |
| 5742 | if (type_entry->data.array.len == 0) | 5738 | // The sentinel counts as an extra element |
| | 5739 | if (type_entry->data.array.len == 0 && type_entry->data.array.sentinel == nullptr) |
| 5743 | return OnePossibleValueYes; | 5740 | return OnePossibleValueYes; |
| 5744 | return type_has_one_possible_value(g, type_entry->data.array.child_type); | 5741 | return type_has_one_possible_value(g, type_entry->data.array.child_type); |
| 5745 | case ZigTypeIdStruct: | 5742 | case ZigTypeIdStruct: |