authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-03 13:11:06-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-03 13:11:06-07:00
log365aca0e9096ef7c69b3ba2eb682caf3f7234293
treee86a89067a08d9c14d01334b4f054b51637afdb8
parent85610a9aff70b3ef77ae63289f8adde1ce5cac37

Sema: allow pointers to opaques to be aligned


1 files changed, 3 insertions(+), 5 deletions(-)

src/type.zig+3-5
......@@ -2245,6 +2245,7 @@ pub const Type = extern union {
22452245 .prefetch_options,
22462246 .export_options,
22472247 .extern_options,
2248 .@"opaque",
22482249 => return 1,
22492250
22502251 .fn_noreturn_no_args, // represents machine code; not a pointer
......@@ -2432,7 +2433,6 @@ pub const Type = extern union {
24322433 .noreturn,
24332434 .inferred_alloc_const,
24342435 .inferred_alloc_mut,
2435 .@"opaque",
24362436 .var_args_param,
24372437 .bound_fn,
24382438 => unreachable,
......@@ -5287,10 +5287,8 @@ pub const Type = extern union {
52875287 // type, we change it to 0 here. If this causes an assertion trip because the
52885288 // pointee type needs to be resolved more, that needs to be done before calling
52895289 // this ptr() function.
5290 if (d.@"align" != 0) {
5291 if (d.pointee_type.zigTypeTag() == .Opaque or d.@"align" == d.pointee_type.abiAlignment(target)) {
5292 d.@"align" = 0;
5293 }
5290 if (d.@"align" != 0 and d.@"align" == d.pointee_type.abiAlignment(target)) {
5291 d.@"align" = 0;
52945292 }
52955293
52965294 // Canonicalize host_size. If it matches the bit size of the pointee type,