diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-02-25 13:10:29 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-02-25 17:38:56 -0500 |
| commit | 55ea855e2cefe8dcdb5fab9be66aa6ca3acd0370 (patch) | |
| tree | 8b08c867108b6e589ea5e6504728199a4482fbd5 /test/compile_errors.zig | |
| parent | 89812217b4e5fee7e2851266c17c9d47204a1573 (diff) | |
| download | zig-55ea855e2cefe8dcdb5fab9be66aa6ca3acd0370.tar.gz zig-55ea855e2cefe8dcdb5fab9be66aa6ca3acd0370.zip | |
ir: Various fixes for comptime ptr handling
* Correctly fold ptrToInt on optional types
* Generate null as ConstPtrSpecialNull in intToPtr
* Correctly stop ptrToInt on ?*T where T is zero-sized
Closes #4535
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 56df006e82..138f7a7633 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -3,6 +3,15 @@ const builtin = @import("builtin"); const Target = @import("std").Target; pub fn addCases(cases: *tests.CompileErrorContext) void { + cases.addTest("@ptrToInt with pointer to zero-sized type", + \\export fn entry() void { + \\ var pointer: ?*u0 = null; + \\ var x = @ptrToInt(pointer); + \\} + , &[_][]const u8{ + "tmp.zig:3:23: error: pointer to size 0 type has no address", + }); + cases.addTest("slice to pointer conversion mismatch", \\pub fn bytesAsSlice(bytes: var) [*]align(1) const u16 { \\ return @ptrCast([*]align(1) const u16, bytes.ptr)[0..1]; |
