diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-12-18 13:49:41 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-12-18 13:51:15 -0700 |
| commit | 6ed0910d6d974750fe65990983d5347ceacc0186 (patch) | |
| tree | 995cb7403d93934044c9135ff9b466a1c16e1b25 /test/behavior/struct.zig | |
| parent | 40ed6ae8469fd599f0524d294f38365c3bb8a825 (diff) | |
| download | zig-6ed0910d6d974750fe65990983d5347ceacc0186.tar.gz zig-6ed0910d6d974750fe65990983d5347ceacc0186.zip | |
Revert "llvm: fix lowering pointer to final zero-width field of a comptime value"
This reverts commit e0bc5f65b98d154b4318027d56f780b55605e33c.
Caused an assertion failure when running the behavior tests:
```
zig: llvm/lib/IR/Type.cpp:729: static llvm::PointerType* llvm::PointerType::get(llvm::Type*, unsigned int): Assertion `isValidElementType(EltTy) && "Invalid type for pointer element!"' failed.
Aborted (core dumped)
```
Diffstat (limited to 'test/behavior/struct.zig')
| -rw-r--r-- | test/behavior/struct.zig | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig index 0984f7d1e4..db7092ab82 100644 --- a/test/behavior/struct.zig +++ b/test/behavior/struct.zig @@ -1359,33 +1359,23 @@ test "under-aligned struct field" { try expect(result == 1234); } -test "fieldParentPtr of a zero-bit field" { +test "address of zero-bit field is equal to address of only field" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO - const S = struct { - fn testOneType(comptime A: type) !void { - { - const a = A{ .u = 0 }; - const b_ptr = &a.b; - const a_ptr = @fieldParentPtr(A, "b", b_ptr); - try std.testing.expectEqual(&a, a_ptr); - } - { - var a = A{ .u = 0 }; - const b_ptr = &a.b; - const a_ptr = @fieldParentPtr(A, "b", b_ptr); - try std.testing.expectEqual(&a, a_ptr); - } - } - fn doTheTest() !void { - try testOneType(struct { b: void = {}, u: u8 }); - try testOneType(struct { u: u8, b: void = {} }); - } - }; - try S.doTheTest(); - comptime try S.doTheTest(); + { + const A = struct { b: void = {}, u: u8 }; + var a = A{ .u = 0 }; + const a_ptr = @fieldParentPtr(A, "b", &a.b); + try std.testing.expectEqual(&a, a_ptr); + } + { + const A = struct { u: u8, b: void = {} }; + var a = A{ .u = 0 }; + const a_ptr = @fieldParentPtr(A, "b", &a.b); + try std.testing.expectEqual(&a, a_ptr); + } } test "struct field has a pointer to an aligned version of itself" { |
