| ... | @@ -983,7 +983,9 @@ static Error type_val_resolve_zero_bits(CodeGen *g, ConstExprValue *type_val, Zi | ... | @@ -983,7 +983,9 @@ static Error type_val_resolve_zero_bits(CodeGen *g, ConstExprValue *type_val, Zi |
| 983 | if ((type_val->data.x_type->id == ZigTypeIdStruct && | 983 | if ((type_val->data.x_type->id == ZigTypeIdStruct && |
| 984 | type_val->data.x_type->data.structure.resolve_loop_flag_zero_bits) || | 984 | type_val->data.x_type->data.structure.resolve_loop_flag_zero_bits) || |
| 985 | (type_val->data.x_type->id == ZigTypeIdUnion && | 985 | (type_val->data.x_type->id == ZigTypeIdUnion && |
| 986 | type_val->data.x_type->data.unionation.resolve_loop_flag_zero_bits)) | 986 | type_val->data.x_type->data.unionation.resolve_loop_flag_zero_bits) || |
| | 987 | (type_val->data.x_type->id == ZigTypeIdPointer && |
| | 988 | type_val->data.x_type->data.pointer.resolve_loop_flag_zero_bits)) |
| 987 | { | 989 | { |
| 988 | // Does a struct/union which contains a pointer field to itself have bits? Yes. | 990 | // Does a struct/union which contains a pointer field to itself have bits? Yes. |
| 989 | *is_zero_bits = false; | 991 | *is_zero_bits = false; |
| ... | @@ -1105,6 +1107,10 @@ Error type_val_resolve_abi_align(CodeGen *g, ConstExprValue *type_val, uint32_t | ... | @@ -1105,6 +1107,10 @@ Error type_val_resolve_abi_align(CodeGen *g, ConstExprValue *type_val, uint32_t |
| 1105 | if (type_val->special != ConstValSpecialLazy) { | 1107 | if (type_val->special != ConstValSpecialLazy) { |
| 1106 | assert(type_val->special == ConstValSpecialStatic); | 1108 | assert(type_val->special == ConstValSpecialStatic); |
| 1107 | ZigType *ty = type_val->data.x_type; | 1109 | ZigType *ty = type_val->data.x_type; |
| | 1110 | if (ty->id == ZigTypeIdPointer) { |
| | 1111 | *abi_align = g->builtin_types.entry_usize->abi_align; |
| | 1112 | return ErrorNone; |
| | 1113 | } |
| 1108 | if ((err = type_resolve(g, ty, ResolveStatusAlignmentKnown))) | 1114 | if ((err = type_resolve(g, ty, ResolveStatusAlignmentKnown))) |
| 1109 | return err; | 1115 | return err; |
| 1110 | *abi_align = ty->abi_align; | 1116 | *abi_align = ty->abi_align; |
| ... | @@ -5611,6 +5617,14 @@ static Error resolve_pointer_zero_bits(CodeGen *g, ZigType *ty) { | ... | @@ -5611,6 +5617,14 @@ static Error resolve_pointer_zero_bits(CodeGen *g, ZigType *ty) { |
| 5611 | if (ty->abi_size != SIZE_MAX) | 5617 | if (ty->abi_size != SIZE_MAX) |
| 5612 | return ErrorNone; | 5618 | return ErrorNone; |
| 5613 | | 5619 | |
| | 5620 | if (ty->data.pointer.resolve_loop_flag_zero_bits) { |
| | 5621 | ty->abi_size = g->builtin_types.entry_usize->abi_size; |
| | 5622 | ty->size_in_bits = g->builtin_types.entry_usize->size_in_bits; |
| | 5623 | ty->abi_align = g->builtin_types.entry_usize->abi_align; |
| | 5624 | return ErrorNone; |
| | 5625 | } |
| | 5626 | ty->data.pointer.resolve_loop_flag_zero_bits = true; |
| | 5627 | |
| 5614 | ZigType *elem_type = ty->data.pointer.child_type; | 5628 | ZigType *elem_type = ty->data.pointer.child_type; |
| 5615 | | 5629 | |
| 5616 | if ((err = type_resolve(g, elem_type, ResolveStatusZeroBitsKnown))) | 5630 | if ((err = type_resolve(g, elem_type, ResolveStatusZeroBitsKnown))) |