Skip to content

Commit d99fc46

Browse files
author
Daniel Kroening
committed
use union_tag_type instead of symbol_type
1 parent d9d9e2a commit d99fc46

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/ansi-c/c_typecheck_type.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ 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_union_tag)
97+
{
98+
}
9699
else if(type.id()==ID_vector)
97100
typecheck_vector_type(to_vector_type(type));
98101
else if(type.id()==ID_custom_unsignedbv ||
@@ -795,12 +798,24 @@ void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type)
795798
}
796799
}
797800

798-
symbol_typet symbol_type(identifier);
799-
symbol_type.add_source_location()=type.source_location();
801+
if(type.id() == ID_union)
802+
{
803+
union_tag_typet tag_type(identifier);
804+
tag_type.add_source_location() = type.source_location();
805+
806+
c_qualifierst original_qualifiers(type);
807+
type.swap(tag_type);
808+
original_qualifiers.write(type);
809+
}
810+
else
811+
{
812+
symbol_typet symbol_type(identifier);
813+
symbol_type.add_source_location() = type.source_location();
800814

801-
c_qualifierst original_qualifiers(type);
802-
type.swap(symbol_type);
803-
original_qualifiers.write(type);
815+
c_qualifierst original_qualifiers(type);
816+
type.swap(symbol_type);
817+
original_qualifiers.write(type);
818+
}
804819
}
805820

806821
void c_typecheck_baset::typecheck_compound_body(

src/goto-symex/goto_symex_state.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,8 @@ 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)
763+
if(member_expr.struct_op().type().id()!=ID_symbol &&
764+
member_expr.struct_op().type().id()!=ID_union_tag)
764765
{
765766
const struct_union_typet &su_type=
766767
to_struct_union_type(member_expr.struct_op().type());

0 commit comments

Comments
 (0)