stage2: make hasCodeGenBits() always true for pointers

* LLVM backend: The `alloc` AIR instruction as well as pointer
   constants which point to a 0-bit element type now call a common
   codepath to produce a `*const llvm.Value` which is a non-zero pointer
   with a bogus-but-properly-aligned address.
 * LLVM backend: improve the lowering of optional types.
 * Type: `hasCodeGenBits()` now returns `true` for pointers even when
   it returns `false` for their element types.

Effectively, #6706 is now implemented in stage2 but not stage1.
This commit is contained in:
Andrew Kelley
2021-10-15 17:17:59 -07:00
parent 0536c25578
commit 186126c2a4
6 changed files with 83 additions and 38 deletions

View File

@@ -36,3 +36,11 @@ test "self-referential struct through a slice of optional" {
var n = S.Node.new();
try expect(n.data == null);
}
pub const EmptyStruct = struct {};
test "optional pointer to size zero struct" {
var e = EmptyStruct{};
var o: ?*EmptyStruct = &e;
try expect(o != null);
}