@@ -436,58 +436,50 @@ symbolt &cpp_declarator_convertert::convert_new_symbol(
436436 symbol.base_name =base_name;
437437 symbol.value =declarator.value ();
438438 symbol.location =declarator.name ().source_location ();
439+ symbol.is_extern = storage_spec.is_extern ();
439440 symbol.is_parameter = declarator.get_is_parameter ();
441+ symbol.is_weak = storage_spec.is_weak ();
440442 symbol.mode =linkage_spec==ID_auto?ID_cpp:linkage_spec;
441443 symbol.module =cpp_typecheck.module ;
442444 symbol.type =final_type;
443445 symbol.is_type =is_typedef;
444446 symbol.is_macro =is_typedef && !is_template_parameter;
445447 symbol.pretty_name =pretty_name;
446448
449+ if (is_code && !symbol.is_type )
450+ {
451+ // it is a function
452+ symbol.is_static_lifetime = false ;
453+ symbol.is_thread_local = false ;
447454
448- if (member_spec.is_inline ())
449- symbol.type .set (ID_C_inlined, true );
455+ symbol.is_file_local = storage_spec.is_static ();
450456
451- if (!symbol.is_type )
457+ if (member_spec.is_inline ())
458+ symbol.type .set (ID_C_inlined, true );
459+ }
460+ else
452461 {
453- if (is_code)
454- {
455- // it is a function
456- if (storage_spec.is_static ())
457- symbol.is_file_local =true ;
458- }
459- else
460- {
461- // it is a variable
462- symbol.is_state_var =true ;
463- symbol.is_lvalue = !is_reference (symbol.type ) &&
464- !(symbol.type .get_bool (ID_C_constant) &&
465- is_number (symbol.type ) &&
466- symbol.value .id () == ID_constant);
467-
468- if (cpp_typecheck.cpp_scopes .current_scope ().is_global_scope ())
469- {
470- symbol.is_static_lifetime =true ;
471-
472- if (storage_spec.is_extern ())
473- symbol.is_extern =true ;
474- }
475- else
476- {
477- if (storage_spec.is_static ())
478- {
479- symbol.is_static_lifetime =true ;
480- symbol.is_file_local =true ;
481- }
482- else if (storage_spec.is_extern ())
483- {
484- cpp_typecheck.error ().source_location =storage_spec.location ();
485- cpp_typecheck.error () << " external storage not permitted here"
486- << messaget::eom;
487- throw 0 ;
488- }
489- }
490- }
462+ symbol.is_lvalue = !is_reference (symbol.type ) &&
463+ !(symbol.type .get_bool (ID_C_constant) &&
464+ is_number (symbol.type ) &&
465+ symbol.value .id () == ID_constant);
466+
467+ symbol.is_static_lifetime =
468+ !symbol.is_macro && !symbol.is_type &&
469+ (cpp_typecheck.cpp_scopes .current_scope ().is_global_scope () ||
470+ storage_spec.is_static ());
471+
472+ symbol.is_thread_local =
473+ (!symbol.is_static_lifetime && !storage_spec.is_extern ()) ||
474+ storage_spec.is_thread_local ();
475+
476+ symbol.is_file_local =
477+ symbol.is_macro ||
478+ (!cpp_typecheck.cpp_scopes .current_scope ().is_global_scope () &&
479+ !storage_spec.is_extern ()) ||
480+ (cpp_typecheck.cpp_scopes .current_scope ().is_global_scope () &&
481+ storage_spec.is_static ()) ||
482+ symbol.is_parameter ;
491483 }
492484
493485 if (symbol.is_static_lifetime )
0 commit comments