@@ -53,6 +53,9 @@ symbolt &cpp_declarator_convertert::convert(
53
53
final_type=declarator.merge_type (declaration_type);
54
54
assert (final_type.is_not_nil ());
55
55
56
+ cpp_storage_spect final_storage_spec = storage_spec;
57
+ final_storage_spec |= cpp_storage_spect (final_type);
58
+
56
59
cpp_template_args_non_tct template_args;
57
60
58
61
// run resolver on scope
@@ -135,7 +138,7 @@ symbolt &cpp_declarator_convertert::convert(
135
138
if (!maybe_symbol && is_friend)
136
139
{
137
140
symbolt &friend_symbol =
138
- convert_new_symbol (storage_spec , member_spec, declarator);
141
+ convert_new_symbol (final_storage_spec , member_spec, declarator);
139
142
// mark it as weak so that the full declaration can replace the symbol
140
143
friend_symbol.is_weak = true ;
141
144
return friend_symbol;
@@ -191,7 +194,7 @@ symbolt &cpp_declarator_convertert::convert(
191
194
type, declarator.member_initializers ());
192
195
}
193
196
194
- if (!storage_spec .is_extern ())
197
+ if (!final_storage_spec .is_extern ())
195
198
symbol.is_extern =false ;
196
199
197
200
// initializer?
@@ -217,10 +220,10 @@ symbolt &cpp_declarator_convertert::convert(
217
220
const auto maybe_symbol=
218
221
cpp_typecheck.symbol_table .get_writeable (final_identifier);
219
222
if (!maybe_symbol)
220
- return convert_new_symbol (storage_spec , member_spec, declarator);
223
+ return convert_new_symbol (final_storage_spec , member_spec, declarator);
221
224
symbolt &symbol=*maybe_symbol;
222
225
223
- if (!storage_spec .is_extern ())
226
+ if (!final_storage_spec .is_extern ())
224
227
symbol.is_extern = false ;
225
228
226
229
if (declarator.get_bool (ID_C_template_case))
@@ -447,6 +450,9 @@ symbolt &cpp_declarator_convertert::convert_new_symbol(
447
450
symbol.base_name =base_name;
448
451
symbol.value =declarator.value ();
449
452
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 ();
450
456
symbol.mode =linkage_spec==ID_auto?ID_cpp:linkage_spec;
451
457
symbol.module =cpp_typecheck.module ;
452
458
symbol.type =final_type;
@@ -459,49 +465,40 @@ symbolt &cpp_declarator_convertert::convert_new_symbol(
459
465
symbol.value .is_not_nil ())
460
466
symbol.is_macro =true ;
461
467
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 )
466
469
{
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 ;
485
473
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 ;
505
502
}
506
503
507
504
if (symbol.is_static_lifetime )
0 commit comments