Skip to content

Commit 1be7572

Browse files
authored
Merge pull request #3778 from tautschnig/deprecation-union_exprt
Construct union_exprt in a non-deprecated way
2 parents c6d6879 + 61bb77a commit 1be7572

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,10 +1111,8 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr)
11111111
if(base_type_eq(c.type(), op.type(), *this))
11121112
{
11131113
// found! build union constructor
1114-
union_exprt union_expr(expr.type());
1114+
union_exprt union_expr(c.get_name(), op, expr.type());
11151115
union_expr.add_source_location()=expr.source_location();
1116-
union_expr.op()=op;
1117-
union_expr.set_component_name(c.get_name());
11181116
expr=union_expr;
11191117
expr.set(ID_C_lvalue, true);
11201118
return;

src/util/expr_initializer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,6 @@ exprt expr_initializert<nondet>::expr_initializer_rec(
219219
const union_typet::componentst &components=
220220
to_union_type(type).components();
221221

222-
union_exprt value(type);
223-
224222
union_typet::componentt component;
225223
bool found=false;
226224
mp_integer component_size=0;
@@ -243,12 +241,12 @@ exprt expr_initializert<nondet>::expr_initializer_rec(
243241
}
244242
}
245243

244+
union_exprt value("", nil_exprt(), type);
246245
value.add_source_location()=source_location;
247246

248247
if(!found)
249248
{
250249
// stupid empty union
251-
value.op()=nil_exprt();
252250
}
253251
else
254252
{

0 commit comments

Comments
 (0)