diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2025-02-22 11:47:22 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-02-22 22:47:32 -0500 |
| commit | 220f80e71dbcb9dac4ed71845573a95b75299e4c (patch) | |
| tree | d9ea138fd8c4c56284ad4cb767afb2b07077f3bd /src/Type.zig | |
| parent | 4b0f77cc1f2f4939c59e92175f6e69394eb3bcef (diff) | |
| download | zig-220f80e71dbcb9dac4ed71845573a95b75299e4c.tar.gz zig-220f80e71dbcb9dac4ed71845573a95b75299e4c.zip | |
Dwarf: fix lowering of comptime-only optional pointer `null` values
Closes #22974
Diffstat (limited to 'src/Type.zig')
| -rw-r--r-- | src/Type.zig | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/Type.zig b/src/Type.zig index 1d30894aba..3208cf522d 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -808,7 +808,7 @@ pub fn isNoReturn(ty: Type, zcu: *const Zcu) bool { return zcu.intern_pool.isNoReturn(ty.toIntern()); } -/// Returns `none` if the pointer is naturally aligned and the element type is 0-bit. +/// Never returns `none`. Asserts that all necessary type resolution is already done. pub fn ptrAlignment(ty: Type, zcu: *Zcu) Alignment { return ptrAlignmentInner(ty, .normal, zcu, {}) catch unreachable; } @@ -825,15 +825,9 @@ pub fn ptrAlignmentInner( ) !Alignment { return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { .ptr_type => |ptr_type| { - if (ptr_type.flags.alignment != .none) - return ptr_type.flags.alignment; - - if (strat == .sema) { - const res = try Type.fromInterned(ptr_type.child).abiAlignmentInner(.sema, zcu, tid); - return res.scalar; - } - - return Type.fromInterned(ptr_type.child).abiAlignment(zcu); + if (ptr_type.flags.alignment != .none) return ptr_type.flags.alignment; + const res = try Type.fromInterned(ptr_type.child).abiAlignmentInner(strat.toLazy(), zcu, tid); + return res.scalar; }, .opt_type => |child| Type.fromInterned(child).ptrAlignmentInner(strat, zcu, tid), else => unreachable, |
