From 5eaead6a56ed95c200e249737c4ecf3c7cacf794 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 25 Mar 2019 12:55:45 -0400 Subject: implement allowzero pointer attribute closes #1953 only needed for freestanding targets. also adds safety for `@intToPtr` when the address is zero. --- test/compile_errors.zig | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/compile_errors.zig') diff --git a/test/compile_errors.zig b/test/compile_errors.zig index a193095b0f..edfb73fc42 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -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 { -- cgit v1.2.3