File tree 1 file changed +30
-0
lines changed
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(
42
42
return false ;
43
43
}
44
44
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
+
45
69
// / We rewrite u.c for unions u into byte_extract(u, 0), and { .c = v } into
46
70
// / byte_update(NIL, 0, v)
47
71
void rewrite_union (
48
72
exprt &expr,
49
73
const namespacet &ns)
50
74
{
75
+ if (expr.id ()==ID_address_of)
76
+ {
77
+ rewrite_union_address_of (to_address_of_expr (expr).object (), ns);
78
+ return ;
79
+ }
80
+
51
81
if (!have_to_rewrite_union (expr, ns))
52
82
return ;
53
83
You can’t perform that action at this time.
0 commit comments