@@ -53,6 +53,9 @@ symbolt &cpp_declarator_convertert::convert(
5353 final_type=declarator.merge_type (declaration_type);
5454 assert (final_type.is_not_nil ());
5555
56+ cpp_storage_spect final_storage_spec = storage_spec;
57+ final_storage_spec |= cpp_storage_spect (final_type);
58+
5659 cpp_template_args_non_tct template_args;
5760
5861 // run resolver on scope
@@ -135,7 +138,7 @@ symbolt &cpp_declarator_convertert::convert(
135138 if (!maybe_symbol && is_friend)
136139 {
137140 symbolt &friend_symbol =
138- convert_new_symbol (storage_spec , member_spec, declarator);
141+ convert_new_symbol (final_storage_spec , member_spec, declarator);
139142 // mark it as weak so that the full declaration can replace the symbol
140143 friend_symbol.is_weak = true ;
141144 return friend_symbol;
@@ -191,7 +194,7 @@ symbolt &cpp_declarator_convertert::convert(
191194 type, declarator.member_initializers ());
192195 }
193196
194- if (!storage_spec .is_extern ())
197+ if (!final_storage_spec .is_extern ())
195198 symbol.is_extern =false ;
196199
197200 // initializer?
@@ -217,10 +220,10 @@ symbolt &cpp_declarator_convertert::convert(
217220 const auto maybe_symbol=
218221 cpp_typecheck.symbol_table .get_writeable (final_identifier);
219222 if (!maybe_symbol)
220- return convert_new_symbol (storage_spec , member_spec, declarator);
223+ return convert_new_symbol (final_storage_spec , member_spec, declarator);
221224 symbolt &symbol=*maybe_symbol;
222225
223- if (!storage_spec .is_extern ())
226+ if (!final_storage_spec .is_extern ())
224227 symbol.is_extern = false ;
225228
226229 if (declarator.get_bool (ID_C_template_case))
@@ -447,6 +450,9 @@ symbolt &cpp_declarator_convertert::convert_new_symbol(
447450 symbol.base_name =base_name;
448451 symbol.value =declarator.value ();
449452 symbol.location =declarator.name ().source_location ();
453+ symbol.is_extern = storage_spec.is_extern ();
454+ symbol.is_parameter = declarator.get_is_parameter ();
455+ symbol.is_weak = storage_spec.is_weak ();
450456 symbol.mode =linkage_spec==ID_auto?ID_cpp:linkage_spec;
451457 symbol.module =cpp_typecheck.module ;
452458 symbol.type =final_type;
@@ -459,49 +465,40 @@ symbolt &cpp_declarator_convertert::convert_new_symbol(
459465 symbol.value .is_not_nil ())
460466 symbol.is_macro =true ;
461467
462- if (member_spec.is_inline ())
463- to_code_type (symbol.type ).set_inlined (true );
464-
465- if (!symbol.is_type )
468+ if (is_code && !symbol.is_type )
466469 {
467- if (is_code)
468- {
469- // it is a function
470- if (storage_spec.is_static ())
471- symbol.is_file_local =true ;
472- }
473- else
474- {
475- // it is a variable
476- symbol.is_state_var =true ;
477- symbol.is_lvalue = !is_reference (symbol.type ) &&
478- !(symbol.type .get_bool (ID_C_constant) &&
479- is_number (symbol.type ) &&
480- symbol.value .id () == ID_constant);
481-
482- if (cpp_typecheck.cpp_scopes .current_scope ().is_global_scope ())
483- {
484- symbol.is_static_lifetime =true ;
470+ // it is a function
471+ symbol.is_static_lifetime = false ;
472+ symbol.is_thread_local = false ;
485473
486- if (storage_spec.is_extern ())
487- symbol.is_extern =true ;
488- }
489- else
490- {
491- if (storage_spec.is_static ())
492- {
493- symbol.is_static_lifetime =true ;
494- symbol.is_file_local =true ;
495- }
496- else if (storage_spec.is_extern ())
497- {
498- cpp_typecheck.error ().source_location =storage_spec.location ();
499- cpp_typecheck.error () << " external storage not permitted here"
500- << messaget::eom;
501- throw 0 ;
502- }
503- }
504- }
474+ symbol.is_file_local = storage_spec.is_static ();
475+
476+ if (member_spec.is_inline ())
477+ to_code_type (symbol.type ).set_inlined (true );
478+ }
479+ else
480+ {
481+ symbol.is_lvalue =
482+ !is_reference (symbol.type ) &&
483+ !(symbol.type .get_bool (ID_C_constant) && is_number (symbol.type ) &&
484+ symbol.value .id () == ID_constant);
485+
486+ symbol.is_static_lifetime =
487+ !symbol.is_macro && !symbol.is_type &&
488+ (cpp_typecheck.cpp_scopes .current_scope ().is_global_scope () ||
489+ storage_spec.is_static ());
490+
491+ symbol.is_thread_local =
492+ (!symbol.is_static_lifetime && !storage_spec.is_extern ()) ||
493+ storage_spec.is_thread_local ();
494+
495+ symbol.is_file_local =
496+ symbol.is_macro ||
497+ (!cpp_typecheck.cpp_scopes .current_scope ().is_global_scope () &&
498+ !storage_spec.is_extern ()) ||
499+ (cpp_typecheck.cpp_scopes .current_scope ().is_global_scope () &&
500+ storage_spec.is_static ()) ||
501+ symbol.is_parameter ;
505502 }
506503
507504 if (symbol.is_static_lifetime )
0 commit comments