From 21bf3b80666c14c9b2a2e1ec984a6b4bb23a5bb7 Mon Sep 17 00:00:00 2001 From: Robin Voetter Date: Tue, 26 Oct 2021 00:51:46 +0200 Subject: stage2: runtime c pointer null comparison --- src/type.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/type.zig') diff --git a/src/type.zig b/src/type.zig index e77780d9ca..7ac235e68e 100644 --- a/src/type.zig +++ b/src/type.zig @@ -2347,11 +2347,13 @@ pub const Type = extern union { } } - /// Asserts that the type is an optional + /// Asserts that the type is an optional or a pointer that can be null. pub fn isPtrLikeOptional(self: Type) bool { switch (self.tag()) { .optional_single_const_pointer, .optional_single_mut_pointer, + .c_const_pointer, + .c_mut_pointer, => return true, .optional => { @@ -2367,6 +2369,8 @@ pub const Type = extern union { .Many, .One => return !info.@"allowzero", } }, + + .pointer => return self.castTag(.pointer).?.data.size == .C, else => unreachable, } } -- cgit v1.2.3