From fc7a0c4878dac2d721ec18cafe1b6bcff7faa771 Mon Sep 17 00:00:00 2001 From: Alex Rønne Petersen Date: Sat, 15 Feb 2025 02:44:58 +0100 Subject: Sema: Fix fnptr alignment safety checks to account for potential ISA tag. As seen on e.g. Arm/Thumb and MIPS (MIPS16/microMIPS). Fixes #22888. --- src/Type.zig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Type.zig') diff --git a/src/Type.zig b/src/Type.zig index 7ddd43b034..883c752ef1 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -2541,6 +2541,13 @@ pub fn fnIsVarArgs(ty: Type, zcu: *const Zcu) bool { return zcu.intern_pool.indexToKey(ty.toIntern()).func_type.is_var_args; } +pub fn fnPtrMaskOrNull(ty: Type, zcu: *const Zcu) ?u64 { + return switch (ty.zigTypeTag(zcu)) { + .@"fn" => target_util.functionPointerMask(zcu.getTarget()), + else => null, + }; +} + pub fn isNumeric(ty: Type, zcu: *const Zcu) bool { return switch (ty.toIntern()) { .f16_type, -- cgit v1.2.3