Skip to content

Commit 65cd9a2

Browse files
committed
Remove dead code
The front-ends handle type conversion when doing arithmetic over enum types. The case of an enum tag is not expected here.
1 parent 6eb9142 commit 65cd9a2

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/goto-programs/goto_convert_side_effect.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,10 @@ void goto_convertt::remove_assignment(
105105
tmp.op0().make_typecast(expr.op1().type());
106106
rhs=typecast_exprt(is_not_zero(tmp, ns), expr.op0().type());
107107
}
108-
else if(op0_type.id() == ID_c_enum_tag)
109-
{
110-
// We convert c_enums to their underlying type, do the
111-
// operation, and then convert back
112-
const auto &enum_type = ns.follow_tag(to_c_enum_tag_type(op0_type));
113-
auto underlying_type = enum_type.subtype();
114-
auto op0 = typecast_exprt(expr.op0(), underlying_type);
115-
auto op1 = typecast_exprt(expr.op1(), underlying_type);
116-
binary_exprt tmp(op0, new_id, op1, underlying_type);
117-
rhs = typecast_exprt(tmp, expr.op0().type());
118-
}
119108
else
120109
{
110+
PRECONDITION(
111+
op0_type.id() != ID_c_enum_tag && op0_type.id() != ID_c_enum);
121112
rhs.id(new_id);
122113
rhs.copy_to_operands(expr.op0(), expr.op1());
123114
rhs.type()=expr.op0().type();

0 commit comments

Comments
 (0)