Skip to content

Commit 424569f

Browse files
author
Daniel Kroening
committed
further support for struct/union tags
1 parent 5dde4be commit 424569f

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/ansi-c/c_typecheck_code.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,12 @@ bool c_typecheck_baset::is_complete_type(const typet &type) const
383383
}
384384
else if(type.id()==ID_vector)
385385
return is_complete_type(type.subtype());
386-
else if(type.id() == ID_symbol_type)
386+
else if(
387+
type.id() == ID_symbol_type || type.id() == ID_struct_tag ||
388+
type.id() == ID_union_tag)
389+
{
387390
return is_complete_type(follow(type));
391+
}
388392

389393
return true;
390394
}

src/goto-instrument/dump_c.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,12 @@ void dump_ct::convert_compound(
322322
if(!system_symbols.is_symbol_internal_symbol(symbol, system_headers))
323323
convert_compound(symbol.type, unresolved, recursive, os);
324324
}
325-
else if(type.id()==ID_c_enum_tag)
325+
else if(
326+
type.id() == ID_c_enum_tag || type.id() == ID_struct_tag ||
327+
type.id() == ID_union_tag)
326328
{
327-
const symbolt &symbol=
328-
ns.lookup(to_c_enum_tag_type(type).get_identifier());
329-
DATA_INVARIANT(symbol.is_type, "symbol expected to be type symbol");
329+
const symbolt &symbol = ns.lookup(to_tag_type(type));
330+
DATA_INVARIANT(symbol.is_type, "tag expected to be type symbol");
330331

331332
if(!system_symbols.is_symbol_internal_symbol(symbol, system_headers))
332333
convert_compound(symbol.type, unresolved, recursive, os);
@@ -674,6 +675,13 @@ void dump_ct::collect_typedefs_rec(
674675
ns.lookup(to_symbol_type(type).get_identifier());
675676
collect_typedefs_rec(symbol.type, early, local_deps);
676677
}
678+
else if(
679+
type.id() == ID_c_enum_tag || type.id() == ID_struct_tag ||
680+
type.id() == ID_union_tag)
681+
{
682+
const symbolt &symbol = ns.lookup(to_tag_type(type));
683+
collect_typedefs_rec(symbol.type, early, local_deps);
684+
}
677685

678686
const irep_idt &typedef_str=type.get(ID_C_typedef);
679687

src/util/std_types.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ bool is_constant_or_has_constant_components(
234234
// we have to use the namespace to resolve to its definition:
235235
// struct t { const int a; };
236236
// struct t t1;
237-
if(type.id() == ID_symbol_type)
237+
if(type.id() == ID_symbol_type ||
238+
type.id() == ID_struct_tag ||
239+
type.id() == ID_union_tag)
238240
{
239241
const auto &resolved_type = ns.follow(type);
240242
return has_constant_components(resolved_type);

0 commit comments

Comments
 (0)