parent
5fd3af9dc6
commit
8c77c5705f
@ -20254,6 +20254,11 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
|
||||
bigint_write_twos_complement(&val->data.x_bigint, buf, val->type->data.integral.bit_count,
|
||||
codegen->is_big_endian);
|
||||
return;
|
||||
case ZigTypeIdEnum:
|
||||
bigint_write_twos_complement(&val->data.x_enum_tag, buf,
|
||||
val->type->data.enumeration.tag_int_type->data.integral.bit_count,
|
||||
codegen->is_big_endian);
|
||||
return;
|
||||
case ZigTypeIdFloat:
|
||||
float_write_ieee597(val, buf, codegen->is_big_endian);
|
||||
return;
|
||||
@ -20285,8 +20290,6 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
|
||||
zig_panic("TODO buf_write_value_bytes error union");
|
||||
case ZigTypeIdErrorSet:
|
||||
zig_panic("TODO buf_write_value_bytes pure error type");
|
||||
case ZigTypeIdEnum:
|
||||
zig_panic("TODO buf_write_value_bytes enum type");
|
||||
case ZigTypeIdFn:
|
||||
zig_panic("TODO buf_write_value_bytes fn type");
|
||||
case ZigTypeIdUnion:
|
||||
|
@ -16,3 +16,20 @@ fn conv(x: i32) u32 {
|
||||
fn conv2(x: u32) i32 {
|
||||
return @bitCast(i32, x);
|
||||
}
|
||||
|
||||
test "@bitCast extern enum to its integer type" {
|
||||
const SOCK = extern enum {
|
||||
A,
|
||||
B,
|
||||
|
||||
fn testBitCastExternEnum() void {
|
||||
var SOCK_DGRAM = @This().B;
|
||||
var sock_dgram = @bitCast(c_int, SOCK_DGRAM);
|
||||
assert(sock_dgram == 1);
|
||||
}
|
||||
};
|
||||
|
||||
SOCK.testBitCastExternEnum();
|
||||
comptime SOCK.testBitCastExternEnum();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user