| ... | ... | @@ -640,13 +640,19 @@ test "array of array agregate init" { |
| 640 | 640 | test "pointer to array has ptr field" { |
| 641 | 641 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 642 | 642 | |
| 643 | | const arr: *const [5]u32 = &.{ 10, 20, 30, 40, 50 }; |
| 644 | | try std.testing.expect(arr.ptr == @as([*]const u32, arr)); |
| 645 | | try std.testing.expect(arr.ptr[0] == 10); |
| 646 | | try std.testing.expect(arr.ptr[1] == 20); |
| 647 | | try std.testing.expect(arr.ptr[2] == 30); |
| 648 | | try std.testing.expect(arr.ptr[3] == 40); |
| 649 | | try std.testing.expect((&arr.ptr).*[4] == 50); |
| 643 | const S = struct { |
| 644 | fn doTheTest(p: *const [5]u32) !void { |
| 645 | try std.testing.expect(p.ptr == @as([*]const u32, p)); |
| 646 | try std.testing.expect(p.ptr[0] == 10); |
| 647 | try std.testing.expect(p.ptr[1] == 20); |
| 648 | try std.testing.expect(p.ptr[2] == 30); |
| 649 | try std.testing.expect(p.ptr[3] == 40); |
| 650 | try std.testing.expect((&p.ptr).*[4] == 50); |
| 651 | } |
| 652 | }; |
| 653 | const arr: [5]u32 = .{ 10, 20, 30, 40, 50 }; |
| 654 | try comptime S.doTheTest(&arr); |
| 655 | try S.doTheTest(&arr); |
| 650 | 656 | } |
| 651 | 657 | |
| 652 | 658 | test "discarded array init preserves result location" { |