| ... | ... | @@ -23393,8 +23393,13 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 23393 | 23393 | const field_name_src = block.builtinCallArgSrc(extra.src_node, 0); |
| 23394 | 23394 | const field_ptr_src = block.builtinCallArgSrc(extra.src_node, 1); |
| 23395 | 23395 | |
| 23396 | | const parent_ptr_ty = try sema.resolveDestType(block, inst_src, extra.parent_ptr_type, .remove_eu, "@fieldParentPtr"); |
| 23397 | | try sema.checkPtrType(block, inst_src, parent_ptr_ty, true); |
| 23396 | const maybe_opt_parent_ptr_ty = try sema.resolveDestType(block, inst_src, extra.parent_ptr_type, .remove_eu, "@fieldParentPtr"); |
| 23397 | try sema.checkPtrType(block, inst_src, maybe_opt_parent_ptr_ty, true); |
| 23398 | const parent_ptr_ty = switch (maybe_opt_parent_ptr_ty.zigTypeTag(zcu)) { |
| 23399 | .optional => maybe_opt_parent_ptr_ty.optionalChild(zcu), |
| 23400 | .pointer => maybe_opt_parent_ptr_ty, |
| 23401 | else => unreachable, |
| 23402 | }; |
| 23398 | 23403 | const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu); |
| 23399 | 23404 | if (parent_ptr_info.flags.size != .one) { |
| 23400 | 23405 | return sema.fail(block, inst_src, "expected single pointer type, found '{f}'", .{parent_ptr_ty.fmt(pt)}); |
| ... | ... | @@ -23441,7 +23446,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 23441 | 23446 | ); |
| 23442 | 23447 | |
| 23443 | 23448 | const unaligned_parent_ptr_ty = try pt.ptrType(info: { |
| 23444 | | var info = parent_ptr_ty.ptrInfo(zcu); |
| 23449 | var info = parent_ptr_info; |
| 23445 | 23450 | info.flags.alignment = hypothetical_field_ptr_ty.ptrAlignment(zcu); |
| 23446 | 23451 | break :info info; |
| 23447 | 23452 | }); |
| ... | ... | @@ -23512,7 +23517,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 23512 | 23517 | // a field pointer of type `*align(1) u16`. |
| 23513 | 23518 | switch (hypothetical_field_ptr_ty.ptrAlignment(zcu).order(parent_ptr_ty.ptrAlignment(zcu))) { |
| 23514 | 23519 | .gt => unreachable, // getting a field pointer can never increase alignment |
| 23515 | | .eq => return unaligned_parent_ptr, |
| 23520 | .eq => return sema.coerce(block, maybe_opt_parent_ptr_ty, unaligned_parent_ptr, inst_src), |
| 23516 | 23521 | .lt => if (flags.align_cast) { |
| 23517 | 23522 | // Go through `ptrCastFull` for the safety check. |
| 23518 | 23523 | return sema.ptrCastFull( |
| ... | ... | @@ -23521,7 +23526,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 23521 | 23526 | inst_src, |
| 23522 | 23527 | unaligned_parent_ptr, |
| 23523 | 23528 | inst_src, |
| 23524 | | parent_ptr_ty, |
| 23529 | maybe_opt_parent_ptr_ty, |
| 23525 | 23530 | "@fieldParentPtr", |
| 23526 | 23531 | ); |
| 23527 | 23532 | } else return sema.failWithOwnedErrorMsg(block, msg: { |
| ... | ... | @@ -25184,7 +25189,7 @@ pub fn explainWhyTypeIsNotExtern( |
| 25184 | 25189 | } |
| 25185 | 25190 | }, |
| 25186 | 25191 | .@"union" => { |
| 25187 | | const union_obj = zcu.intern_pool.loadStructType(ty.toIntern()); |
| 25192 | const union_obj = zcu.intern_pool.loadUnionType(ty.toIntern()); |
| 25188 | 25193 | switch (union_obj.layout) { |
| 25189 | 25194 | .auto => try sema.errNote(src_loc, msg, "union with automatic layout has no guaranteed in-memory representation", .{}), |
| 25190 | 25195 | .@"extern" => unreachable, |