authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-25 21:16:03-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-25 21:16:03-04:00
loga7f31581850fe2811bc5114459a8d193dd48b42a
tree43558519a50429e82954ac3dfae92e3d458d6062
parent64e9b0ee4673bf79d42ea14e354b324308f90b93
signaturelock-open Commit is signed but in an unrecognized format.

behavior tests passing


1 files changed, 14 insertions(+), 3 deletions(-)

src/analyze.cpp+14-3
...@@ -2633,7 +2633,7 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {...@@ -2633,7 +2633,7 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
2633 decl_node->data.container_decl.init_arg_expr != nullptr)2633 decl_node->data.container_decl.init_arg_expr != nullptr)
2634 {2634 {
2635 union_field->type_entry = g->builtin_types.entry_void;2635 union_field->type_entry = g->builtin_types.entry_void;
2636 field_is_zero_bits = false;2636 field_is_zero_bits = true;
2637 } else {2637 } else {
2638 add_node_error(g, field_node, buf_sprintf("union field missing type"));2638 add_node_error(g, field_node, buf_sprintf("union field missing type"));
2639 union_type->data.unionation.resolve_status = ResolveStatusInvalid;2639 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
...@@ -5593,6 +5593,10 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {...@@ -5593,6 +5593,10 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
55935593
5594static Error resolve_pointer_zero_bits(CodeGen *g, ZigType *ty) {5594static Error resolve_pointer_zero_bits(CodeGen *g, ZigType *ty) {
5595 Error err;5595 Error err;
5596
5597 if (ty->abi_size != SIZE_MAX)
5598 return ErrorNone;
5599
5596 ZigType *elem_type = ty->data.pointer.child_type;5600 ZigType *elem_type = ty->data.pointer.child_type;
55975601
5598 if ((err = type_resolve(g, elem_type, ResolveStatusZeroBitsKnown)))5602 if ((err = type_resolve(g, elem_type, ResolveStatusZeroBitsKnown)))
...@@ -5641,6 +5645,8 @@ Error type_resolve(CodeGen *g, ZigType *ty, ResolveStatus status) {...@@ -5641,6 +5645,8 @@ Error type_resolve(CodeGen *g, ZigType *ty, ResolveStatus status) {
5641 return resolve_union_alignment(g, ty);5645 return resolve_union_alignment(g, ty);
5642 case ZigTypeIdFnFrame:5646 case ZigTypeIdFnFrame:
5643 return resolve_async_frame(g, ty);5647 return resolve_async_frame(g, ty);
5648 case ZigTypeIdPointer:
5649 return resolve_pointer_zero_bits(g, ty);
5644 default:5650 default:
5645 return ErrorNone;5651 return ErrorNone;
5646 }5652 }
...@@ -5654,6 +5660,8 @@ Error type_resolve(CodeGen *g, ZigType *ty, ResolveStatus status) {...@@ -5654,6 +5660,8 @@ Error type_resolve(CodeGen *g, ZigType *ty, ResolveStatus status) {
5654 return resolve_union_type(g, ty);5660 return resolve_union_type(g, ty);
5655 case ZigTypeIdFnFrame:5661 case ZigTypeIdFnFrame:
5656 return resolve_async_frame(g, ty);5662 return resolve_async_frame(g, ty);
5663 case ZigTypeIdPointer:
5664 return resolve_pointer_zero_bits(g, ty);
5657 default:5665 default:
5658 return ErrorNone;5666 return ErrorNone;
5659 }5667 }
...@@ -7386,7 +7394,8 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta...@@ -7386,7 +7394,8 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta
73867394
7387 TypeUnionField *most_aligned_union_member = union_type->data.unionation.most_aligned_union_member;7395 TypeUnionField *most_aligned_union_member = union_type->data.unionation.most_aligned_union_member;
7388 ZigType *tag_type = union_type->data.unionation.tag_type;7396 ZigType *tag_type = union_type->data.unionation.tag_type;
7389 if (most_aligned_union_member == nullptr) {7397 uint32_t gen_field_count = union_type->data.unionation.gen_field_count;
7398 if (gen_field_count == 0) {
7390 union_type->llvm_type = get_llvm_type(g, tag_type);7399 union_type->llvm_type = get_llvm_type(g, tag_type);
7391 union_type->llvm_di_type = get_llvm_di_type(g, tag_type);7400 union_type->llvm_di_type = get_llvm_di_type(g, tag_type);
7392 union_type->data.unionation.resolve_status = ResolveStatusLLVMFull;7401 union_type->data.unionation.resolve_status = ResolveStatusLLVMFull;
...@@ -7410,7 +7419,6 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta...@@ -7410,7 +7419,6 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta
7410 if (ResolveStatusLLVMFwdDecl >= wanted_resolve_status) return;7419 if (ResolveStatusLLVMFwdDecl >= wanted_resolve_status) return;
7411 }7420 }
74127421
7413 uint32_t gen_field_count = union_type->data.unionation.gen_field_count;
7414 ZigLLVMDIType **union_inner_di_types = allocate<ZigLLVMDIType*>(gen_field_count);7422 ZigLLVMDIType **union_inner_di_types = allocate<ZigLLVMDIType*>(gen_field_count);
7415 uint32_t field_count = union_type->data.unionation.src_field_count;7423 uint32_t field_count = union_type->data.unionation.src_field_count;
7416 for (uint32_t i = 0; i < field_count; i += 1) {7424 for (uint32_t i = 0; i < field_count; i += 1) {
...@@ -7541,6 +7549,9 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta...@@ -7541,6 +7549,9 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta
7541static void resolve_llvm_types_pointer(CodeGen *g, ZigType *type, ResolveStatus wanted_resolve_status) {7549static void resolve_llvm_types_pointer(CodeGen *g, ZigType *type, ResolveStatus wanted_resolve_status) {
7542 if (type->llvm_di_type != nullptr) return;7550 if (type->llvm_di_type != nullptr) return;
75437551
7552 if (resolve_pointer_zero_bits(g, type) != ErrorNone)
7553 zig_unreachable();
7554
7544 if (!type_has_bits(type)) {7555 if (!type_has_bits(type)) {
7545 type->llvm_type = g->builtin_types.entry_void->llvm_type;7556 type->llvm_type = g->builtin_types.entry_void->llvm_type;
7546 type->llvm_di_type = g->builtin_types.entry_void->llvm_di_type;7557 type->llvm_di_type = g->builtin_types.entry_void->llvm_di_type;