From d00da05ecbeca36e8ca25dcb1238bf98b38081a5 Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Mon, 11 Jul 2022 17:54:53 +0300 Subject: Sema: validate extern types --- src/type.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/type.zig') diff --git a/src/type.zig b/src/type.zig index f14ad3a85b..765f1da18c 100644 --- a/src/type.zig +++ b/src/type.zig @@ -3935,7 +3935,6 @@ pub const Type = extern union { /// Returns true if the type is optional and would be lowered to a single pointer /// address value, using 0 for null. Note that this returns true for C pointers. - /// See also `hasOptionalRepr`. pub fn isPtrLikeOptional(self: Type) bool { switch (self.tag()) { .optional_single_const_pointer, @@ -4630,6 +4629,14 @@ pub const Type = extern union { }; } + /// Asserts the type is a function. + pub fn fnCallingConventionAllowsZigTypes(self: Type) bool { + return switch (self.fnCallingConvention()) { + .Unspecified, .Async, .Inline, .PtxKernel => true, + else => false, + }; + } + /// Asserts the type is a function. pub fn fnIsVarArgs(self: Type) bool { return switch (self.tag()) { -- cgit v1.2.3