aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2021-10-26 00:51:46 +0200
committerRobin Voetter <robin@voetter.nl>2021-10-26 01:24:14 +0200
commit21bf3b80666c14c9b2a2e1ec984a6b4bb23a5bb7 (patch)
tree36e906cf5c4a40a715ed53f058feaccacf73ab8a /src/type.zig
parent4eb7b28700b23d8465a36e364e60394b2a1da41b (diff)
downloadzig-21bf3b80666c14c9b2a2e1ec984a6b4bb23a5bb7.tar.gz
zig-21bf3b80666c14c9b2a2e1ec984a6b4bb23a5bb7.zip
stage2: runtime c pointer null comparison
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig6
1 files changed, 5 insertions, 1 deletions
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,
}
}