mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
spirv: implement arithmeticTypeInfo for Enum (@intToEnum)
This commit is contained in:
parent
9c550721e4
commit
f8de4db873
@ -369,6 +369,17 @@ pub const DeclGen = struct {
|
|||||||
.composite_integer,
|
.composite_integer,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
.Enum => blk: {
|
||||||
|
var buffer: Type.Payload.Bits = undefined;
|
||||||
|
const int_ty = ty.intTagType(&buffer);
|
||||||
|
const int_info = int_ty.intInfo(target);
|
||||||
|
break :blk ArithmeticTypeInfo{
|
||||||
|
.bits = int_info.bits,
|
||||||
|
.is_vector = false,
|
||||||
|
.signedness = int_info.signedness,
|
||||||
|
.class = .integer,
|
||||||
|
};
|
||||||
|
},
|
||||||
// As of yet, there is no vector support in the self-hosted compiler.
|
// As of yet, there is no vector support in the self-hosted compiler.
|
||||||
.Vector => self.todo("implement arithmeticTypeInfo for Vector", .{}),
|
.Vector => self.todo("implement arithmeticTypeInfo for Vector", .{}),
|
||||||
// TODO: For which types is this the case?
|
// TODO: For which types is this the case?
|
||||||
|
|||||||
@ -27,7 +27,6 @@ const IntToEnumNumber = enum { Zero, One, Two, Three, Four };
|
|||||||
test "int to enum" {
|
test "int to enum" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
|
||||||
|
|
||||||
try testIntToEnumEval(3);
|
try testIntToEnumEval(3);
|
||||||
}
|
}
|
||||||
@ -576,8 +575,6 @@ test "enum literal equality" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "enum literal cast to enum" {
|
test "enum literal cast to enum" {
|
||||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
|
||||||
|
|
||||||
const Color = enum { Auto, Off, On };
|
const Color = enum { Auto, Off, On };
|
||||||
|
|
||||||
var color1: Color = .Auto;
|
var color1: Color = .Auto;
|
||||||
@ -874,8 +871,6 @@ test "switch on enum with one member is comptime-known" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "method call on an enum" {
|
test "method call on an enum" {
|
||||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
|
||||||
|
|
||||||
const S = struct {
|
const S = struct {
|
||||||
const E = enum {
|
const E = enum {
|
||||||
one,
|
one,
|
||||||
|
|||||||
@ -366,7 +366,6 @@ test "simple union(enum(u32))" {
|
|||||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
|
||||||
|
|
||||||
var x = MultipleChoice.C;
|
var x = MultipleChoice.C;
|
||||||
try expect(x == MultipleChoice.C);
|
try expect(x == MultipleChoice.C);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user