implement allowzero pointer attribute
closes #1953 only needed for freestanding targets. also adds safety for `@intToPtr` when the address is zero.
This commit is contained in:
@@ -2,6 +2,15 @@ const tests = @import("tests.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"@ptrToInt 0 to non optional pointer",
|
||||
\\export fn entry() void {
|
||||
\\ var b = @intToPtr(*i32, 0);
|
||||
\\}
|
||||
,
|
||||
"tmp.zig:2:13: error: pointer type '*i32' does not allow address zero",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"cast enum literal to enum but it doesn't match",
|
||||
\\const Foo = enum {
|
||||
|
||||
Reference in New Issue
Block a user