diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-12-02 18:51:26 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-12-03 00:09:23 +0200 |
| commit | 7f9e841f746bb3eaf6ac205092a30bc7ed12a068 (patch) | |
| tree | 14b168089558d7c1c27a0ea2f6f69b8d1fbc1813 /src/type.zig | |
| parent | 59dad43de26a89ca72a97224a171d724dcc6ee41 (diff) | |
| download | zig-7f9e841f746bb3eaf6ac205092a30bc7ed12a068.tar.gz zig-7f9e841f746bb3eaf6ac205092a30bc7ed12a068.zip | |
Sema: do not forcibly canonicalize unresolved pointer element type
Closes #13308
Diffstat (limited to 'src/type.zig')
| -rw-r--r-- | src/type.zig | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/type.zig b/src/type.zig index 5fcd0f6a26..46b33a34fa 100644 --- a/src/type.zig +++ b/src/type.zig @@ -6491,8 +6491,16 @@ pub const Type = extern union { // type, we change it to 0 here. If this causes an assertion trip because the // pointee type needs to be resolved more, that needs to be done before calling // this ptr() function. - if (d.@"align" != 0 and d.@"align" == d.pointee_type.abiAlignment(target)) { - d.@"align" = 0; + if (d.@"align" != 0) canonicalize: { + if (d.pointee_type.castTag(.@"struct")) |struct_ty| { + if (!struct_ty.data.haveLayout()) break :canonicalize; + } + if (d.pointee_type.cast(Payload.Union)) |union_ty| { + if (!union_ty.data.haveLayout()) break :canonicalize; + } + if (d.@"align" == d.pointee_type.abiAlignment(target)) { + d.@"align" = 0; + } } // Canonicalize host_size. If it matches the bit size of the pointee type, |
