diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-09-25 13:39:46 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-09-25 13:39:46 -0400 |
| commit | 683da0e4ecd336f9a74098d49d5748bdc1ed2f70 (patch) | |
| tree | fa16c8486981f6d8497c0eca319c3fcdb5bf75fa /src/analyze.cpp | |
| parent | e06885d64e3569719e9479c7069da7ad426a70d3 (diff) | |
| download | zig-683da0e4ecd336f9a74098d49d5748bdc1ed2f70.tar.gz zig-683da0e4ecd336f9a74098d49d5748bdc1ed2f70.zip | |
ability to have struct to have a field which is slice of itself
closes #197
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index b3cf10737c..09eb823e9d 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -1589,6 +1589,9 @@ static void resolve_struct_type(CodeGen *g, ImportTableEntry *import, TypeTableE TypeTableEntry *field_type = type_struct_field->type_entry; + assert(field_type->type_ref); + assert(struct_type->type_ref); + assert(struct_type->data.structure.complete); uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, field_type->type_ref); uint64_t debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, field_type->type_ref); uint64_t debug_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, struct_type->type_ref, @@ -4065,7 +4068,8 @@ static TypeTableEntry *analyze_array_type(CodeGen *g, ImportTableEntry *import, { AstNode *size_node = node->data.array_type.size; - TypeTableEntry *child_type = analyze_type_expr(g, import, context, node->data.array_type.child_type); + TypeTableEntry *child_type = analyze_type_expr_pointer_only(g, import, context, + node->data.array_type.child_type, true); if (child_type->id == TypeTableEntryIdUnreachable) { add_node_error(g, node, buf_create_from_str("array of unreachable not allowed")); @@ -4075,6 +4079,7 @@ static TypeTableEntry *analyze_array_type(CodeGen *g, ImportTableEntry *import, } if (size_node) { + child_type = analyze_type_expr(g, import, context, node->data.array_type.child_type); TypeTableEntry *size_type = analyze_expression(g, import, context, g->builtin_types.entry_usize, size_node); if (size_type->id == TypeTableEntryIdInvalid) { @@ -4101,8 +4106,8 @@ static TypeTableEntry *analyze_array_type(CodeGen *g, ImportTableEntry *import, return g->builtin_types.entry_invalid; } } else { - return resolve_expr_const_val_as_type(g, node, - get_slice_type(g, child_type, node->data.array_type.is_const), false); + TypeTableEntry *slice_type = get_slice_type(g, child_type, node->data.array_type.is_const); + return resolve_expr_const_val_as_type(g, node, slice_type, false); } } |
