@@ -168,11 +168,9 @@ void dump_ct::operator()(std::ostream &os)
168168 const symbolt &symbol=ns.lookup (*it);
169169 const irep_idt &type_id=symbol.type .id ();
170170
171- if (symbol.is_type &&
172- symbol.location .get_function ().empty () &&
173- (type_id==ID_struct ||
174- type_id==ID_union ||
175- type_id==ID_c_enum))
171+ if (
172+ symbol.is_type && !symbol.has_local_scope &&
173+ (type_id == ID_struct || type_id == ID_union || type_id == ID_c_enum))
176174 {
177175 if (!system_symbols.is_symbol_internal_symbol (symbol, system_headers))
178176 {
@@ -293,7 +291,7 @@ void dump_ct::convert_compound_declaration(
293291 const symbolt &symbol,
294292 std::ostream &os_body)
295293{
296- if (! symbol.location . get_function (). empty () )
294+ if (symbol.has_local_scope )
297295 return ;
298296
299297 // do compound type body
@@ -737,8 +735,7 @@ void dump_ct::gather_global_typedefs()
737735 {
738736 const symbolt &symbol=symbol_entry.second ;
739737
740- if (symbol.is_macro && symbol.is_type &&
741- symbol.location .get_function ().empty ())
738+ if (symbol.is_macro && symbol.is_type && !symbol.has_local_scope )
742739 {
743740 const irep_idt &typedef_str=symbol.type .get (ID_C_typedef);
744741 PRECONDITION (!typedef_str.empty ());
@@ -843,9 +840,10 @@ void dump_ct::convert_global_variable(
843840 std::ostream &os,
844841 local_static_declst &local_static_decls)
845842{
846- const irep_idt &func=symbol.location .get_function ();
847- if ((func.empty () || symbol.is_extern || symbol.value .is_not_nil ()) &&
848- !converted_global.insert (symbol.name ).second )
843+ const bool global = !symbol.has_local_scope ;
844+ if (
845+ (global || symbol.is_extern || symbol.value .is_not_nil ()) &&
846+ !converted_global.insert (symbol.name ).second )
849847 return ;
850848
851849 code_declt d (symbol.symbol_expr ());
@@ -856,8 +854,7 @@ void dump_ct::convert_global_variable(
856854
857855 // add a tentative declaration to cater for symbols in the initializer
858856 // relying on it this symbol
859- if ((func.empty () || symbol.is_extern ) &&
860- (symbol.value .is_nil () || !syms.empty ()))
857+ if ((global || symbol.is_extern ) && (symbol.value .is_nil () || !syms.empty ()))
861858 {
862859 os << " // " << symbol.name << ' \n ' ;
863860 os << " // " << symbol.location << ' \n ' ;
@@ -889,7 +886,7 @@ void dump_ct::convert_global_variable(
889886 d.copy_to_operands (symbol.value );
890887 }
891888
892- if (!func. empty () && !symbol.is_extern )
889+ if (!global && !symbol.is_extern )
893890 {
894891 local_static_decls.emplace (symbol.name , d);
895892 }
0 commit comments