File tree 5 files changed +40
-11
lines changed
5 files changed +40
-11
lines changed Original file line number Diff line number Diff line change @@ -444,10 +444,6 @@ symbolt &cpp_declarator_convertert::convert_new_symbol(
444
444
symbol.is_macro =is_typedef && !is_template_parameter;
445
445
symbol.pretty_name =pretty_name;
446
446
447
- // Constant? These are propagated.
448
- if (symbol.type .get_bool (ID_C_constant) &&
449
- symbol.value .is_not_nil ())
450
- symbol.is_macro =true ;
451
447
452
448
if (member_spec.is_inline ())
453
449
symbol.type .set (ID_C_inlined, true );
Original file line number Diff line number Diff line change @@ -58,6 +58,16 @@ std::string cpp_typecheckt::template_suffix(
58
58
else // expression
59
59
{
60
60
exprt e=expr;
61
+
62
+ if (e.id () == ID_symbol)
63
+ {
64
+ const symbol_exprt &s = to_symbol_expr (e);
65
+ const symbolt &symbol = lookup (s.get_identifier ());
66
+
67
+ if (cpp_is_pod (symbol.type ) && symbol.type .get_bool (ID_C_constant))
68
+ e = symbol.value ;
69
+ }
70
+
61
71
make_constant (e);
62
72
63
73
// this must be a constant, which includes true/false
Original file line number Diff line number Diff line change @@ -713,13 +713,6 @@ void cpp_typecheckt::typecheck_compound_declarator(
713
713
{
714
714
new_symbol->value .swap (value);
715
715
c_typecheck_baset::do_initializer (*new_symbol);
716
-
717
- // these are macros if they are PODs and come with a (constant) value
718
- if (new_symbol->type .get_bool (ID_C_constant))
719
- {
720
- simplify (new_symbol->value , *this );
721
- new_symbol->is_macro =true ;
722
- }
723
716
}
724
717
else
725
718
{
@@ -752,7 +745,18 @@ void cpp_typecheckt::check_fixed_size_array(typet &type)
752
745
array_typet &array_type=to_array_type (type);
753
746
754
747
if (array_type.size ().is_not_nil ())
748
+ {
749
+ if (array_type.size ().id () == ID_symbol)
750
+ {
751
+ const symbol_exprt &s = to_symbol_expr (array_type.size ());
752
+ const symbolt &symbol = lookup (s.get_identifier ());
753
+
754
+ if (cpp_is_pod (symbol.type ) && symbol.type .get_bool (ID_C_constant))
755
+ array_type.size () = symbol.value ;
756
+ }
757
+
755
758
make_constant_index (array_type.size ());
759
+ }
756
760
757
761
// recursive call for multi-dimensional arrays
758
762
check_fixed_size_array (array_type.subtype ());
Original file line number Diff line number Diff line change @@ -62,6 +62,8 @@ void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol)
62
62
symbol.type =enum_tag_type;
63
63
symbol.is_type =false ;
64
64
symbol.is_macro =true ;
65
+ symbol.is_file_local = true ;
66
+ symbol.is_thread_local = true ;
65
67
66
68
symbolt *new_symbol;
67
69
if (symbol_table.move (symbol, new_symbol))
Original file line number Diff line number Diff line change @@ -1094,6 +1094,23 @@ symbol_typet cpp_typecheck_resolvet::disambiguate_template_classes(
1094
1094
source_location,
1095
1095
primary_template_symbol,
1096
1096
full_template_args);
1097
+
1098
+ for (auto &arg : full_template_args_tc.arguments ())
1099
+ {
1100
+ if (arg.id () == ID_symbol)
1101
+ {
1102
+ const symbol_exprt &s = to_symbol_expr (arg);
1103
+ const symbolt &symbol = cpp_typecheck.lookup (s.get_identifier ());
1104
+
1105
+ if (
1106
+ cpp_typecheck.cpp_is_pod (symbol.type ) &&
1107
+ symbol.type .get_bool (ID_C_constant))
1108
+ {
1109
+ arg = symbol.value ;
1110
+ }
1111
+ }
1112
+ }
1113
+
1097
1114
// go back to where we used to be
1098
1115
}
1099
1116
You can’t perform that action at this time.
0 commit comments