@@ -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))
@@ -449,6 +452,9 @@ symbolt &cpp_declarator_convertert::convert_new_symbol(
449
452
symbol.base_name =base_name;
450
453
symbol.value =declarator.value ();
451
454
symbol.location =declarator.name ().source_location ();
455
+ symbol.is_extern = storage_spec.is_extern ();
456
+ symbol.is_parameter = declarator.get_is_parameter ();
457
+ symbol.is_weak = storage_spec.is_weak ();
452
458
symbol.mode =linkage_spec==ID_auto?ID_cpp:linkage_spec;
453
459
symbol.module =cpp_typecheck.module ;
454
460
symbol.type =final_type;
@@ -461,49 +467,40 @@ symbolt &cpp_declarator_convertert::convert_new_symbol(
461
467
symbol.value .is_not_nil ())
462
468
symbol.is_macro =true ;
463
469
464
- if (member_spec.is_inline ())
465
- symbol.type .set (ID_C_inlined, true );
466
-
467
- if (!symbol.is_type )
470
+ if (is_code && !symbol.is_type )
468
471
{
469
- if (is_code)
470
- {
471
- // it is a function
472
- if (storage_spec.is_static ())
473
- symbol.is_file_local =true ;
474
- }
475
- else
476
- {
477
- // it is a variable
478
- symbol.is_state_var =true ;
479
- symbol.is_lvalue = !is_reference (symbol.type ) &&
480
- !(symbol.type .get_bool (ID_C_constant) &&
481
- is_number (symbol.type ) &&
482
- symbol.value .id () == ID_constant);
483
-
484
- if (cpp_typecheck.cpp_scopes .current_scope ().is_global_scope ())
485
- {
486
- symbol.is_static_lifetime =true ;
472
+ // it is a function
473
+ symbol.is_static_lifetime = false ;
474
+ symbol.is_thread_local = false ;
487
475
488
- if (storage_spec.is_extern ())
489
- symbol.is_extern =true ;
490
- }
491
- else
492
- {
493
- if (storage_spec.is_static ())
494
- {
495
- symbol.is_static_lifetime =true ;
496
- symbol.is_file_local =true ;
497
- }
498
- else if (storage_spec.is_extern ())
499
- {
500
- cpp_typecheck.error ().source_location =storage_spec.location ();
501
- cpp_typecheck.error () << " external storage not permitted here"
502
- << messaget::eom;
503
- throw 0 ;
504
- }
505
- }
506
- }
476
+ symbol.is_file_local = storage_spec.is_static ();
477
+
478
+ if (member_spec.is_inline ())
479
+ symbol.type .set (ID_C_inlined, true );
480
+ }
481
+ else
482
+ {
483
+ symbol.is_lvalue =
484
+ !is_reference (symbol.type ) &&
485
+ !(symbol.type .get_bool (ID_C_constant) && is_number (symbol.type ) &&
486
+ symbol.value .id () == ID_constant);
487
+
488
+ symbol.is_static_lifetime =
489
+ !symbol.is_macro && !symbol.is_type &&
490
+ (cpp_typecheck.cpp_scopes .current_scope ().is_global_scope () ||
491
+ storage_spec.is_static ());
492
+
493
+ symbol.is_thread_local =
494
+ (!symbol.is_static_lifetime && !storage_spec.is_extern ()) ||
495
+ storage_spec.is_thread_local ();
496
+
497
+ symbol.is_file_local =
498
+ symbol.is_macro ||
499
+ (!cpp_typecheck.cpp_scopes .current_scope ().is_global_scope () &&
500
+ !storage_spec.is_extern ()) ||
501
+ (cpp_typecheck.cpp_scopes .current_scope ().is_global_scope () &&
502
+ storage_spec.is_static ()) ||
503
+ symbol.is_parameter ;
507
504
}
508
505
509
506
if (symbol.is_static_lifetime )
0 commit comments