disallow alignment on packed union fields

This commit is contained in:
David Rubin
2025-08-01 14:57:06 -07:00
parent 5678a600ff
commit e82d67233b
5 changed files with 16 additions and 12 deletions

View File

@@ -5386,6 +5386,9 @@ fn unionDeclInner(
return astgen.failNode(member_node, "union field missing type", .{});
}
if (member.ast.align_expr.unwrap()) |align_expr| {
if (layout == .@"packed") {
return astgen.failNode(align_expr, "unable to override alignment of packed union fields", .{});
}
const align_inst = try expr(&block_scope, &block_scope.base, coerced_align_ri, align_expr);
wip_members.appendToField(@intFromEnum(align_inst));
any_aligned_fields = true;