dwarf: do not assume unsigned 64bit integer for the enum value
This commit is contained in:
@@ -405,8 +405,11 @@ pub const DeclState = struct {
|
||||
const value: u64 = if (values) |vals| value: {
|
||||
if (vals.count() == 0) break :value @intCast(u64, field_i); // auto-numbered
|
||||
const value = vals.keys()[field_i];
|
||||
// TODO do not assume a 64bit enum value - could be bigger.
|
||||
// See https://github.com/ziglang/zig/issues/645
|
||||
var int_buffer: Value.Payload.U64 = undefined;
|
||||
break :value value.enumToInt(ty, &int_buffer).toUnsignedInt(target);
|
||||
const field_int_val = value.enumToInt(ty, &int_buffer);
|
||||
break :value @bitCast(u64, field_int_val.toSignedInt());
|
||||
} else @intCast(u64, field_i);
|
||||
mem.writeInt(u64, dbg_info_buffer.addManyAsArrayAssumeCapacity(8), value, target_endian);
|
||||
}
|
||||
|
||||
@@ -1146,8 +1146,6 @@ test "size of enum with only one tag which has explicit integer tag type" {
|
||||
}
|
||||
|
||||
test "switch on an extern enum with negative value" {
|
||||
// TODO x86, wasm backends fail because they assume that enum tag types are unsigned
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (@import("builtin").zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
|
||||
const Foo = enum(c_int) {
|
||||
|
||||
Reference in New Issue
Block a user