File tree 2 files changed +32
-9
lines changed
2 files changed +32
-9
lines changed Original file line number Diff line number Diff line change @@ -820,12 +820,24 @@ void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type)
820
820
}
821
821
}
822
822
823
- symbol_typet symbol_type (identifier);
824
- symbol_type.add_source_location ()=type.source_location ();
823
+ if (type.id () == ID_union)
824
+ {
825
+ union_tag_typet tag_type (identifier);
826
+ tag_type.add_source_location () = type.source_location ();
827
+
828
+ c_qualifierst original_qualifiers (type);
829
+ type.swap (tag_type);
830
+ original_qualifiers.write (type);
831
+ }
832
+ else
833
+ {
834
+ symbol_typet symbol_type (identifier);
835
+ symbol_type.add_source_location () = type.source_location ();
825
836
826
- c_qualifierst original_qualifiers (type);
827
- type.swap (symbol_type);
828
- original_qualifiers.write (type);
837
+ c_qualifierst original_qualifiers (type);
838
+ type.swap (symbol_type);
839
+ original_qualifiers.write (type);
840
+ }
829
841
}
830
842
831
843
void c_typecheck_baset::typecheck_compound_body (
Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ void cpp_typecheckt::typecheck_compound_type(
135
135
cpp_scopet *dest_scope=nullptr ;
136
136
bool has_body=type.find (ID_body).is_not_nil ();
137
137
bool tag_only_declaration=type.get_bool (ID_C_tag_only_declaration);
138
+ bool is_union=type.id ()==ID_union;
138
139
139
140
if (!has_tag)
140
141
{
@@ -263,10 +264,20 @@ void cpp_typecheckt::typecheck_compound_type(
263
264
}
264
265
}
265
266
266
- // create type symbol
267
- symbol_typet symbol_type (symbol_name);
268
- qualifiers.write (symbol_type);
269
- type.swap (symbol_type);
267
+ if (is_union)
268
+ {
269
+ // create union tag
270
+ union_tag_typet tag_type (symbol_name);
271
+ qualifiers.write (tag_type);
272
+ type.swap (tag_type);
273
+ }
274
+ else
275
+ {
276
+ // create type symbol
277
+ symbol_typet symbol_type (symbol_name);
278
+ qualifiers.write (symbol_type);
279
+ type.swap (symbol_type);
280
+ }
270
281
}
271
282
272
283
void cpp_typecheckt::typecheck_compound_declarator (
You can’t perform that action at this time.
0 commit comments