| ... | @@ -690,9 +690,9 @@ pub fn hasRuntimeBits(ty: Type, zcu: *const Zcu) bool { | ... | @@ -690,9 +690,9 @@ pub fn hasRuntimeBits(ty: Type, zcu: *const Zcu) bool { |
| 690 | }; | 690 | }; |
| 691 | } | 691 | } |
| 692 | | 692 | |
| 693 | /// true if and only if the type has a well-defined memory layout | 693 | /// Returns `true` iff the memory layout of `ty` is defined by the Zig language specification. |
| 694 | /// readFrom/writeToMemory are supported only for types with a well- | 694 | /// |
| 695 | /// defined memory layout | 695 | /// Does not require `ty` to be resolved. |
| 696 | pub fn hasWellDefinedLayout(ty: Type, zcu: *const Zcu) bool { | 696 | pub fn hasWellDefinedLayout(ty: Type, zcu: *const Zcu) bool { |
| 697 | const ip = &zcu.intern_pool; | 697 | const ip = &zcu.intern_pool; |
| 698 | return switch (ip.indexToKey(ty.toIntern())) { | 698 | return switch (ip.indexToKey(ty.toIntern())) { |
| ... | @@ -3140,9 +3140,16 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool | ... | @@ -3140,9 +3140,16 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool |
| 3140 | }, | 3140 | }, |
| 3141 | }; | 3141 | }; |
| 3142 | }, | 3142 | }, |
| 3143 | .array => { | 3143 | .array => switch (position) { |
| 3144 | if (position == .ret_ty or position == .param_ty) return false; | 3144 | .ret_ty, |
| 3145 | return ty.childType(zcu).validateExtern(.element, zcu); | 3145 | .param_ty, |
| | 3146 | => false, |
| | 3147 | |
| | 3148 | .union_field, |
| | 3149 | .struct_field, |
| | 3150 | .element, |
| | 3151 | .other, |
| | 3152 | => ty.childType(zcu).validateExtern(.element, zcu), |
| 3146 | }, | 3153 | }, |
| 3147 | .vector => ty.childType(zcu).validateExtern(.element, zcu), | 3154 | .vector => ty.childType(zcu).validateExtern(.element, zcu), |
| 3148 | .optional => ty.isPtrLikeOptional(zcu), | 3155 | .optional => ty.isPtrLikeOptional(zcu), |