Skip to content

Commit 3c7e964

Browse files
committed
x86_64: implement error set and enum safety
This is all of the expected 0.14.0 progress on #21530, which can now be postponed once this commit is merged. This required rewriting the (un)wrap operations since the original implementations were extremely buggy. Also adds an easy way to retrigger Sema OPV bugs so that I don't have to keep updating #22419 all the time.
1 parent d12123a commit 3c7e964

File tree

5 files changed

+4681
-3904
lines changed

5 files changed

+4681
-3904
lines changed

src/Sema.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8850,7 +8850,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
88508850
// Use `intCast`, since it'll set up the Sema-emitted safety checks for us!
88518851
const int_val = try sema.intCast(block, src, int_tag_ty, src, operand, src, true, true);
88528852
const result = try block.addBitCast(dest_ty, int_val);
8853-
if (zcu.backendSupportsFeature(.is_named_enum_value)) {
8853+
if (!dest_ty.isNonexhaustiveEnum(zcu) and zcu.backendSupportsFeature(.is_named_enum_value)) {
88548854
const ok = try block.addUnOp(.is_named_enum_value, result);
88558855
try sema.addSafetyCheck(block, src, ok, .invalid_enum_value);
88568856
}

src/Type.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,11 +4190,11 @@ pub const @"c_longlong": Type = .{ .ip_index = .c_longlong_type };
41904190
pub const @"c_ulonglong": Type = .{ .ip_index = .c_ulonglong_type };
41914191
pub const @"c_longdouble": Type = .{ .ip_index = .c_longdouble_type };
41924192

4193-
pub const slice_const_u8: Type = .{ .ip_index = .slice_const_u8_type };
41944193
pub const manyptr_u8: Type = .{ .ip_index = .manyptr_u8_type };
4195-
pub const single_const_pointer_to_comptime_int: Type = .{
4196-
.ip_index = .single_const_pointer_to_comptime_int_type,
4197-
};
4194+
pub const manyptr_const_u8: Type = .{ .ip_index = .manyptr_const_u8_type };
4195+
pub const manyptr_const_u8_sentinel_0: Type = .{ .ip_index = .manyptr_const_u8_sentinel_0_type };
4196+
pub const single_const_pointer_to_comptime_int: Type = .{ .ip_index = .single_const_pointer_to_comptime_int_type };
4197+
pub const slice_const_u8: Type = .{ .ip_index = .slice_const_u8_type };
41984198
pub const slice_const_u8_sentinel_0: Type = .{ .ip_index = .slice_const_u8_sentinel_0_type };
41994199

42004200
pub const vector_16_i8: Type = .{ .ip_index = .vector_16_i8_type };

0 commit comments

Comments
 (0)