stage2: implement opaque declarations

* Module: implement opaque type namespace lookup
 * Add `Type.type` for convenience
 * Sema: fix `validateVarType` for pointer-to-opaque
 * x86_64 ABI: implement support for pointers
 * LLVM backend: fix lowering of opaque types
 * Type: implement equality checking for opaques
This commit is contained in:
Andrew Kelley
2021-10-13 17:53:28 -07:00
parent da7fcfd158
commit df7d6d263e
8 changed files with 158 additions and 46 deletions

View File

@@ -188,3 +188,15 @@ fn testMemcpyMemset() !void {
try expect(bar[11] == 'A');
try expect(bar[19] == 'A');
}
const OpaqueA = opaque {};
const OpaqueB = opaque {};
test "variable is allowed to be a pointer to an opaque type" {
var x: i32 = 1234;
_ = hereIsAnOpaqueType(@ptrCast(*OpaqueA, &x));
}
fn hereIsAnOpaqueType(ptr: *OpaqueA) *OpaqueA {
var a = ptr;
return a;
}