mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:04:43 +01:00
Type: fix assertion failure
This commit is contained in:
parent
b28ce1a809
commit
2877a60969
1 changed files with 10 additions and 7 deletions
17
src/Type.zig
17
src/Type.zig
|
|
@ -3094,7 +3094,7 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool
|
|||
if (ty.isSlice(zcu)) return false;
|
||||
const child_ty = ty.childType(zcu);
|
||||
if (child_ty.zigTypeTag(zcu) == .@"fn") {
|
||||
return ty.isConstPtr(zcu) and child_ty.validateExtern(.other, zcu);
|
||||
return ty.isConstPtr(zcu) and validateExternCallconv(child_ty.fnCallingConvention(zcu));
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
|
@ -3104,12 +3104,7 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool
|
|||
},
|
||||
.@"fn" => {
|
||||
if (position != .other) return false;
|
||||
// For now we want to authorize PTX kernel to use zig objects, even if we end up exposing the ABI.
|
||||
// The goal is to experiment with more integrated CPU/GPU code.
|
||||
if (ty.fnCallingConvention(zcu) == .nvptx_kernel) {
|
||||
return true;
|
||||
}
|
||||
return !target_util.fnCallConvAllowsZigTypes(ty.fnCallingConvention(zcu));
|
||||
return validateExternCallconv(ty.fnCallingConvention(zcu));
|
||||
},
|
||||
.@"enum" => {
|
||||
const enum_obj = zcu.intern_pool.loadEnumType(ty.toIntern());
|
||||
|
|
@ -3155,6 +3150,14 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool
|
|||
.optional => ty.isPtrLikeOptional(zcu),
|
||||
};
|
||||
}
|
||||
fn validateExternCallconv(cc: std.builtin.CallingConvention) bool {
|
||||
return switch (cc) {
|
||||
// For now we want to authorize PTX kernel to use zig objects, even if we end up exposing the ABI.
|
||||
// The goal is to experiment with more integrated CPU/GPU code.
|
||||
.nvptx_kernel => true,
|
||||
else => !target_util.fnCallConvAllowsZigTypes(cc),
|
||||
};
|
||||
}
|
||||
|
||||
/// Asserts that `ty` has resolved layout.
|
||||
pub fn assertHasLayout(ty: Type, zcu: *const Zcu) void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue