aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-12-02 18:51:26 +0200
committerVeikka Tuominen <git@vexu.eu>2022-12-03 00:09:23 +0200
commit7f9e841f746bb3eaf6ac205092a30bc7ed12a068 (patch)
tree14b168089558d7c1c27a0ea2f6f69b8d1fbc1813 /src/type.zig
parent59dad43de26a89ca72a97224a171d724dcc6ee41 (diff)
downloadzig-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.zig12
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,