Skip to content

Simplify integer -> enum-tag type casts #4178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/util/simplify_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,17 @@ bool simplify_exprt::simplify_typecast(exprt &expr)
expr=from_integer(int_value, expr_type);
return false;
}
else if(expr_type_id == ID_c_enum_tag)
{
const auto &c_enum_type = ns.follow_tag(to_c_enum_tag_type(expr_type));
if(!c_enum_type.is_incomplete()) // possibly incomplete
{
exprt tmp = from_integer(int_value, c_enum_type);
tmp.type() = expr_type; // we maintain the tag type
expr = tmp;
return false;
}
}
}
else if(op_type_id==ID_rational)
{
Expand Down