Skip to content

Commit 338042e

Browse files
author
Daniel Kroening
committed
introduce union_tag type instead of symbol_type
1 parent 0d9cb4b commit 338042e

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/ansi-c/c_typecheck_type.cpp

+17-5
Original file line numberDiff line numberDiff line change
@@ -800,12 +800,24 @@ void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type)
800800
}
801801
}
802802

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

806-
c_qualifierst original_qualifiers(type);
807-
type.swap(symbol_type);
808-
original_qualifiers.write(type);
817+
c_qualifierst original_qualifiers(type);
818+
type.swap(symbol_type);
819+
original_qualifiers.write(type);
820+
}
809821
}
810822

811823
void c_typecheck_baset::typecheck_compound_body(

0 commit comments

Comments
 (0)