Skip to content

Commit b64fd46

Browse files
Fix C enum JSON output
The subtype must be used.
1 parent 79ea945 commit b64fd46

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/goto-programs/json_expr.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ json_objectt json(const typet &type, const namespacet &ns, const irep_idt &mode)
206206

207207
static std::string binary(const constant_exprt &src)
208208
{
209-
const auto width = to_bitvector_type(src.type()).get_width();
209+
std::size_t width;
210+
if(src.type().id() == ID_c_enum)
211+
width = to_bitvector_type(to_c_enum_type(src.type()).subtype()).get_width();
212+
else
213+
width = to_bitvector_type(src.type()).get_width();
210214
const auto int_val = bvrep2integer(src.get_value(), width, false);
211215
return integer2binary(int_val, width);
212216
}

0 commit comments

Comments
 (0)