aboutsummaryrefslogtreecommitdiff
path: root/test/stage1/behavior
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-02-25 13:10:29 +0100
committerAndrew Kelley <andrew@ziglang.org>2020-02-25 17:38:56 -0500
commit55ea855e2cefe8dcdb5fab9be66aa6ca3acd0370 (patch)
tree8b08c867108b6e589ea5e6504728199a4482fbd5 /test/stage1/behavior
parent89812217b4e5fee7e2851266c17c9d47204a1573 (diff)
downloadzig-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/stage1/behavior')
-rw-r--r--test/stage1/behavior/pointers.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/stage1/behavior/pointers.zig b/test/stage1/behavior/pointers.zig
index fdaa5867d7..bcc1d62df3 100644
--- a/test/stage1/behavior/pointers.zig
+++ b/test/stage1/behavior/pointers.zig
@@ -318,3 +318,15 @@ test "pointer arithmetic affects the alignment" {
expect(@typeInfo(@TypeOf(ptr4)).Pointer.alignment == 4);
}
}
+
+test "@ptrToInt on null optional at comptime" {
+ {
+ const pointer = @intToPtr(?*u8, 0x000);
+ const x = @ptrToInt(pointer);
+ comptime expect(0 == @ptrToInt(pointer));
+ }
+ {
+ const pointer = @intToPtr(?*u8, 0xf00);
+ comptime expect(0xf00 == @ptrToInt(pointer));
+ }
+}