Skip to content

Commit b77a297

Browse files
committed
Do not mark arbitrary constants as macros
1 parent df50446 commit b77a297

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/cpp/cpp_declarator_converter.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,6 @@ symbolt &cpp_declarator_convertert::convert_new_symbol(
427427
symbol.is_macro=is_typedef && !is_template_parameter;
428428
symbol.pretty_name=pretty_name;
429429

430-
// Constant? These are propagated.
431-
if(symbol.type.get_bool(ID_C_constant) &&
432-
symbol.value.is_not_nil())
433-
symbol.is_macro=true;
434430

435431
if(member_spec.is_inline())
436432
symbol.type.set(ID_C_inlined, true);

src/cpp/cpp_typecheck_compound_type.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -734,13 +734,6 @@ void cpp_typecheckt::typecheck_compound_declarator(
734734
{
735735
new_symbol->value.swap(value);
736736
c_typecheck_baset::do_initializer(*new_symbol);
737-
738-
// these are macros if they are PODs and come with a (constant) value
739-
if(new_symbol->type.get_bool(ID_C_constant))
740-
{
741-
simplify(new_symbol->value, *this);
742-
new_symbol->is_macro=true;
743-
}
744737
}
745738
else
746739
{
@@ -772,7 +765,18 @@ void cpp_typecheckt::check_fixed_size_array(typet &type)
772765
array_typet &array_type=to_array_type(type);
773766

774767
if(array_type.size().is_not_nil())
768+
{
769+
if(array_type.size().id() == ID_symbol)
770+
{
771+
const symbol_exprt &s = to_symbol_expr(array_type.size());
772+
const symbolt &symbol = lookup(s.get_identifier());
773+
774+
if(cpp_is_pod(symbol.type) && symbol.type.get_bool(ID_C_constant))
775+
array_type.size() = symbol.value;
776+
}
777+
775778
make_constant_index(array_type.size());
779+
}
776780

777781
// recursive call for multi-dimensional arrays
778782
check_fixed_size_array(array_type.subtype());

src/cpp/cpp_typecheck_enum_type.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol)
6363
symbol.type=enum_tag_type;
6464
symbol.is_type=false;
6565
symbol.is_macro=true;
66+
symbol.is_file_local = true;
67+
symbol.is_thread_local = true;
6668

6769
symbolt *new_symbol;
6870
if(symbol_table.move(symbol, new_symbol))

0 commit comments

Comments
 (0)