authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-18 11:19:24-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-19 09:53:55-04:00
loge947f0c7409c719377ca08fb09ec72a558a60d99
tree36d3fc5ed977837dcd57feaef56b7f57b03b8ec4
parent72a261b4d35b4f720e189150eb5e73e0fa52ae35
signaturelock-open Commit is signed but in an unrecognized format.

0-bit array type does not resolve child type


1 files changed, 6 insertions(+), 4 deletions(-)

src/analyze.cpp+6-4
......@@ -780,6 +780,8 @@ ZigType *get_error_union_type(CodeGen *g, ZigType *err_set_type, ZigType *payloa
780780}
781781
782782ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size, ZigValue *sentinel) {
783 Error err;
784
783785 TypeId type_id = {};
784786 type_id.id = ZigTypeIdArray;
785787 type_id.data.array.codegen = g;
......@@ -791,8 +793,9 @@ ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size, Zi
791793 return existing_entry->value;
792794 }
793795
794 Error err;
795 if ((err = type_resolve(g, child_type, ResolveStatusSizeKnown))) {
796 size_t full_array_size = array_size + ((sentinel != nullptr) ? 1 : 0);
797
798 if (full_array_size != 0 && (err = type_resolve(g, child_type, ResolveStatusSizeKnown))) {
796799 codegen_report_errors_and_exit(g);
797800 }
798801
......@@ -806,9 +809,8 @@ ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size, Zi
806809 }
807810 buf_appendf(&entry->name, "]%s", buf_ptr(&child_type->name));
808811
809 size_t full_array_size = array_size + ((sentinel != nullptr) ? 1 : 0);
810812 entry->size_in_bits = child_type->size_in_bits * full_array_size;
811 entry->abi_align = child_type->abi_align;
813 entry->abi_align = (full_array_size == 0) ? 0 : child_type->abi_align;
812814 entry->abi_size = child_type->abi_size * full_array_size;
813815
814816 entry->data.array.child_type = child_type;