add compile error for intToPtr with a 0-bit ptr

See #323
This commit is contained in:
Andrew Kelley
2017-04-17 19:28:33 -04:00
parent 216e14891e
commit 2e0b114fdc
2 changed files with 14 additions and 0 deletions

View File

@@ -1895,6 +1895,13 @@ export fn entry() {
const foo = Arch.x86;
}
)SOURCE", 1, ".tmp_source.zig:3:21: error: container 'Arch' has no member called 'x86'");
add_compile_fail_case("int to ptr of 0 bits", R"SOURCE(
export fn foo() {
var x: usize = 0x1000;
var y: &void = @intToPtr(&void, x);
}
)SOURCE", 1, ".tmp_source.zig:4:31: error: type '&void' has 0 bits and cannot store information");
}
//////////////////////////////////////////////////////////////////////////////