File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -42,12 +42,42 @@ static bool have_to_rewrite_union(
4242 return false ;
4343}
4444
45+ // inside an address of (&x), unions can simply
46+ // be type casts and don't have to be re-written!
47+ void rewrite_union_address_of (
48+ exprt &expr,
49+ const namespacet &ns)
50+ {
51+ if (!have_to_rewrite_union (expr, ns))
52+ return ;
53+
54+ if (expr.id ()==ID_index)
55+ {
56+ rewrite_union_address_of (to_index_expr (expr).array (), ns);
57+ rewrite_union (to_index_expr (expr).index (), ns);
58+ }
59+ else if (expr.id ()==ID_member)
60+ rewrite_union_address_of (to_member_expr (expr).struct_op (), ns);
61+ else if (expr.id ()==ID_symbol)
62+ {
63+ // done!
64+ }
65+ else if (expr.id ()==ID_dereference)
66+ rewrite_union (to_dereference_expr (expr).pointer (), ns);
67+ }
68+
4569// / We rewrite u.c for unions u into byte_extract(u, 0), and { .c = v } into
4670// / byte_update(NIL, 0, v)
4771void rewrite_union (
4872 exprt &expr,
4973 const namespacet &ns)
5074{
75+ if (expr.id ()==ID_address_of)
76+ {
77+ rewrite_union_address_of (to_address_of_expr (expr).object (), ns);
78+ return ;
79+ }
80+
5181 if (!have_to_rewrite_union (expr, ns))
5282 return ;
5383
You can’t perform that action at this time.
0 commit comments