zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 365aca0e9096ef7c69b3ba2eb682caf3f7234293 (tree)
parent 85610a9aff70b3ef77ae63289f8adde1ce5cac37
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Thu,  3 Mar 2022 13:11:06 -0700

Sema: allow pointers to opaques to be aligned

Diffstat:
Msrc/type.zig | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/type.zig b/src/type.zig @@ -2245,6 +2245,7 @@ pub const Type = extern union { .prefetch_options, .export_options, .extern_options, + .@"opaque", => return 1, .fn_noreturn_no_args, // represents machine code; not a pointer @@ -2432,7 +2433,6 @@ pub const Type = extern union { .noreturn, .inferred_alloc_const, .inferred_alloc_mut, - .@"opaque", .var_args_param, .bound_fn, => unreachable, @@ -5287,10 +5287,8 @@ 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) { - if (d.pointee_type.zigTypeTag() == .Opaque or d.@"align" == d.pointee_type.abiAlignment(target)) { - d.@"align" = 0; - } + if (d.@"align" != 0 and d.@"align" == d.pointee_type.abiAlignment(target)) { + d.@"align" = 0; } // Canonicalize host_size. If it matches the bit size of the pointee type,