Sema: allow pointers to opaques to be aligned

This commit is contained in:
Andrew Kelley 2022-03-03 13:11:06 -07:00
parent 85610a9aff
commit 365aca0e90

View File

@ -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,