@@ -168,11 +168,9 @@ void dump_ct::operator()(std::ostream &os)
168
168
const symbolt &symbol=ns.lookup (*it);
169
169
const irep_idt &type_id=symbol.type .id ();
170
170
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))
176
174
{
177
175
if (!system_symbols.is_symbol_internal_symbol (symbol, system_headers))
178
176
{
@@ -293,7 +291,7 @@ void dump_ct::convert_compound_declaration(
293
291
const symbolt &symbol,
294
292
std::ostream &os_body)
295
293
{
296
- if (! symbol.location . get_function (). empty () )
294
+ if (symbol.has_local_scope )
297
295
return ;
298
296
299
297
// do compound type body
@@ -737,8 +735,7 @@ void dump_ct::gather_global_typedefs()
737
735
{
738
736
const symbolt &symbol=symbol_entry.second ;
739
737
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 )
742
739
{
743
740
const irep_idt &typedef_str=symbol.type .get (ID_C_typedef);
744
741
PRECONDITION (!typedef_str.empty ());
@@ -843,9 +840,10 @@ void dump_ct::convert_global_variable(
843
840
std::ostream &os,
844
841
local_static_declst &local_static_decls)
845
842
{
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 )
849
847
return ;
850
848
851
849
code_declt d (symbol.symbol_expr ());
@@ -856,8 +854,7 @@ void dump_ct::convert_global_variable(
856
854
857
855
// add a tentative declaration to cater for symbols in the initializer
858
856
// 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 ()))
861
858
{
862
859
os << " // " << symbol.name << ' \n ' ;
863
860
os << " // " << symbol.location << ' \n ' ;
@@ -889,7 +886,7 @@ void dump_ct::convert_global_variable(
889
886
d.copy_to_operands (symbol.value );
890
887
}
891
888
892
- if (!func. empty () && !symbol.is_extern )
889
+ if (!global && !symbol.is_extern )
893
890
{
894
891
local_static_decls.emplace (symbol.name , d);
895
892
}
0 commit comments