| author | |
| committer | |
| log | 81318e870418d017244d6d133aabca19f2c63b58 |
| tree | cf2798c2ada2b1901f6e2129ea45c6566c40febe |
| parent | 46b49a0a766a39ca37ba48f1a1c2ed28c260b08b |
Closes #140632 files changed, 18 insertions(+), 0 deletions(-)
src/codegen/llvm.zig+4| ... | ... | @@ -1928,6 +1928,7 @@ pub const Object = struct { |
| 1928 | 1928 | if (ty.castTag(.@"struct")) |payload| { |
| 1929 | 1929 | const struct_obj = payload.data; |
| 1930 | 1930 | if (struct_obj.layout == .Packed and struct_obj.haveFieldTypes()) { |
| 1931 | assert(struct_obj.haveLayout()); | |
| 1931 | 1932 | const info = struct_obj.backing_int_ty.intInfo(target); |
| 1932 | 1933 | const dwarf_encoding: c_uint = switch (info.signedness) { |
| 1933 | 1934 | .signed => DW.ATE.signed, |
| ... | ... | @@ -2931,6 +2932,7 @@ pub const DeclGen = struct { |
| 2931 | 2932 | const struct_obj = t.castTag(.@"struct").?.data; |
| 2932 | 2933 | |
| 2933 | 2934 | if (struct_obj.layout == .Packed) { |
| 2935 | assert(struct_obj.haveLayout()); | |
| 2934 | 2936 | const int_llvm_ty = try dg.lowerType(struct_obj.backing_int_ty); |
| 2935 | 2937 | gop.value_ptr.* = int_llvm_ty; |
| 2936 | 2938 | return int_llvm_ty; |
| ... | ... | @@ -3632,6 +3634,7 @@ pub const DeclGen = struct { |
| 3632 | 3634 | const struct_obj = tv.ty.castTag(.@"struct").?.data; |
| 3633 | 3635 | |
| 3634 | 3636 | if (struct_obj.layout == .Packed) { |
| 3637 | assert(struct_obj.haveLayout()); | |
| 3635 | 3638 | const big_bits = struct_obj.backing_int_ty.bitSize(target); |
| 3636 | 3639 | const int_llvm_ty = dg.context.intType(@intCast(c_uint, big_bits)); |
| 3637 | 3640 | const fields = struct_obj.fields.values(); |
| ... | ... | @@ -9152,6 +9155,7 @@ pub const FuncGen = struct { |
| 9152 | 9155 | .Struct => { |
| 9153 | 9156 | if (result_ty.containerLayout() == .Packed) { |
| 9154 | 9157 | const struct_obj = result_ty.castTag(.@"struct").?.data; |
| 9158 | assert(struct_obj.haveLayout()); | |
| 9155 | 9159 | const big_bits = struct_obj.backing_int_ty.bitSize(target); |
| 9156 | 9160 | const int_llvm_ty = self.context.intType(@intCast(c_uint, big_bits)); |
| 9157 | 9161 | const fields = struct_obj.fields.values(); |
test/behavior/struct.zig+14| ... | ... | @@ -1430,6 +1430,12 @@ test "struct has only one reference" { |
| 1430 | 1430 | fn errorUnionStructReturn() error{Foo}!struct { x: u8 } { |
| 1431 | 1431 | return error.Foo; |
| 1432 | 1432 | } |
| 1433 | ||
| 1434 | fn pointerPackedStruct(_: *packed struct { x: u8 }) void {} | |
| 1435 | fn nestedPointerPackedStruct(_: struct { x: *packed struct { x: u8 } }) void {} | |
| 1436 | fn pointerNestedPackedStruct(_: *struct { x: packed struct { x: u8 } }) void {} | |
| 1437 | fn pointerNestedPointerPackedStruct(_: *struct { x: *packed struct { x: u8 } }) void {} | |
| 1438 | ||
| 1433 | 1439 | fn optionalComptimeIntParam(comptime x: ?comptime_int) comptime_int { |
| 1434 | 1440 | return x.?; |
| 1435 | 1441 | } |
| ... | ... | @@ -1446,6 +1452,14 @@ test "struct has only one reference" { |
| 1446 | 1452 | const error_union_struct_return: *const anyopaque = &S.errorUnionStructReturn; |
| 1447 | 1453 | try expect(optional_struct_return != error_union_struct_return); |
| 1448 | 1454 | |
| 1455 | const pointer_packed_struct: *const anyopaque = &S.pointerPackedStruct; | |
| 1456 | const nested_pointer_packed_struct: *const anyopaque = &S.nestedPointerPackedStruct; | |
| 1457 | try expect(pointer_packed_struct != nested_pointer_packed_struct); | |
| 1458 | ||
| 1459 | const pointer_nested_packed_struct: *const anyopaque = &S.pointerNestedPackedStruct; | |
| 1460 | const pointer_nested_pointer_packed_struct: *const anyopaque = &S.pointerNestedPointerPackedStruct; | |
| 1461 | try expect(pointer_nested_packed_struct != pointer_nested_pointer_packed_struct); | |
| 1462 | ||
| 1449 | 1463 | try expectEqual(@alignOf(struct {}), S.optionalComptimeIntParam(@alignOf(struct {}))); |
| 1450 | 1464 | try expectEqual(@alignOf(struct { x: u8 }), S.errorUnionComptimeIntParam(@alignOf(struct { x: u8 }))); |
| 1451 | 1465 | try expectEqual(@sizeOf(struct { x: u16 }), S.optionalComptimeIntParam(@sizeOf(struct { x: u16 }))); |