| author | |
| committer | |
| log | 32d755beb8d83a666100ca9455df51b93caff1fc |
| tree | f17274c9e85736b61dd3cb6cfcb5f2cd446caada |
| parent | 2eb09092065715642e93d9cfd54196840a314bc0 |
| signature |
2 files changed, 15 insertions(+), 0 deletions(-)
src/Sema.zig+4| ... | ... | @@ -17682,6 +17682,10 @@ fn reifyStruct( |
| 17682 | 17682 | } |
| 17683 | 17683 | const abi_align = @intCast(u29, (try alignment_val.getUnsignedIntAdvanced(target, sema.kit(block, src))).?); |
| 17684 | 17684 | |
| 17685 | if (layout == .Packed and abi_align != 0) { | |
| 17686 | return sema.fail(block, src, "alignment in a packed struct field must be set to 0", .{}); | |
| 17687 | } | |
| 17688 | ||
| 17685 | 17689 | const field_name = try name_val.toAllocatedBytes( |
| 17686 | 17690 | Type.initTag(.const_slice_u8), |
| 17687 | 17691 | new_decl_arena_allocator, |
test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | export fn entry() void { | |
| 2 | _ = @Type(.{ .Struct = .{ .layout = .Packed, .fields = &.{ | |
| 3 | .{ .name = "one", .field_type = u4, .default_value = null, .is_comptime = false, .alignment = 2 }, | |
| 4 | }, .decls = &.{}, .is_tuple = false } }); | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // backend=stage2 | |
| 9 | // target=native | |
| 10 | // | |
| 11 | // :2:9: error: alignment in a packed struct field must be set to 0 |