Skip to content

Commit 307c3bd

Browse files
author
Daniel Kroening
committed
further support for union_tag and struct_tag
1 parent 4e95060 commit 307c3bd

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

src/ansi-c/c_typecheck_type.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ void c_typecheck_baset::typecheck_type(typet &type)
9393
typecheck_symbol_type(to_symbol_type(type));
9494
else if(type.id() == ID_typedef_type)
9595
typecheck_typedef_type(type);
96+
else if(type.id() == ID_struct_tag ||
97+
type.id() == ID_union_tag)
98+
{
99+
// nothing to do, these stay as is
100+
}
96101
else if(type.id()==ID_vector)
97102
typecheck_vector_type(to_vector_type(type));
98103
else if(type.id()==ID_custom_unsignedbv ||

src/goto-symex/goto_symex_state.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,10 @@ void goto_symex_statet::rename_address(
760760

761761
// type might not have been renamed in case of nesting of
762762
// structs and pointers/arrays
763-
if(member_expr.struct_op().type().id() != ID_symbol_type)
763+
if(
764+
member_expr.struct_op().type().id() != ID_symbol_type &&
765+
member_expr.struct_op().type().id() != ID_struct_tag &&
766+
member_expr.struct_op().type().id() != ID_union_tag)
764767
{
765768
const struct_union_typet &su_type=
766769
to_struct_union_type(member_expr.struct_op().type());
@@ -845,8 +848,19 @@ void goto_symex_statet::rename(
845848
}
846849
else if(type.id() == ID_symbol_type)
847850
{
848-
const symbolt &symbol=
849-
ns.lookup(to_symbol_type(type).get_identifier());
851+
const symbolt &symbol = ns.lookup(to_symbol_type(type));
852+
type = symbol.type;
853+
rename(type, l1_identifier, ns, level);
854+
}
855+
else if(type.id() == ID_union_tag)
856+
{
857+
const symbolt &symbol = ns.lookup(to_union_tag_type(type));
858+
type = symbol.type;
859+
rename(type, l1_identifier, ns, level);
860+
}
861+
else if(type.id() == ID_struct_tag)
862+
{
863+
const symbolt &symbol = ns.lookup(to_struct_tag_type(type));
850864
type=symbol.type;
851865
rename(type, l1_identifier, ns, level);
852866
}

src/util/replace_symbol.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,28 @@ bool replace_symbolt::replace(typet &dest) const
197197
result=false;
198198
}
199199
}
200+
else if(dest.id() == ID_union_tag)
201+
{
202+
type_mapt::const_iterator it =
203+
type_map.find(to_union_tag_type(dest).get_identifier());
204+
205+
if(it != type_map.end())
206+
{
207+
dest = it->second;
208+
result = false;
209+
}
210+
}
211+
else if(dest.id() == ID_struct_tag)
212+
{
213+
type_mapt::const_iterator it =
214+
type_map.find(to_struct_tag_type(dest).get_identifier());
215+
216+
if(it != type_map.end())
217+
{
218+
dest = it->second;
219+
result = false;
220+
}
221+
}
200222
else if(dest.id()==ID_array)
201223
{
202224
array_typet &array_type=to_array_type(dest);

0 commit comments

Comments
 (0)