Skip to content

Commit 2dbea60

Browse files
committed
Do not mark arbitrary constants as macros
1 parent f9058e7 commit 2dbea60

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
@@ -437,10 +437,6 @@ symbolt &cpp_declarator_convertert::convert_new_symbol(
437437
symbol.is_macro=is_typedef && !is_template_parameter;
438438
symbol.pretty_name=pretty_name;
439439

440-
// Constant? These are propagated.
441-
if(symbol.type.get_bool(ID_C_constant) &&
442-
symbol.value.is_not_nil())
443-
symbol.is_macro=true;
444440

445441
if(member_spec.is_inline())
446442
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
@@ -709,13 +709,6 @@ void cpp_typecheckt::typecheck_compound_declarator(
709709
{
710710
new_symbol->value.swap(value);
711711
c_typecheck_baset::do_initializer(*new_symbol);
712-
713-
// these are macros if they are PODs and come with a (constant) value
714-
if(new_symbol->type.get_bool(ID_C_constant))
715-
{
716-
simplify(new_symbol->value, *this);
717-
new_symbol->is_macro=true;
718-
}
719712
}
720713
else
721714
{
@@ -748,7 +741,18 @@ void cpp_typecheckt::check_fixed_size_array(typet &type)
748741
array_typet &array_type=to_array_type(type);
749742

750743
if(array_type.size().is_not_nil())
744+
{
745+
if(array_type.size().id() == ID_symbol)
746+
{
747+
const symbol_exprt &s = to_symbol_expr(array_type.size());
748+
const symbolt &symbol = lookup(s.get_identifier());
749+
750+
if(cpp_is_pod(symbol.type) && symbol.type.get_bool(ID_C_constant))
751+
array_type.size() = symbol.value;
752+
}
753+
751754
make_constant_index(array_type.size());
755+
}
752756

753757
// recursive call for multi-dimensional arrays
754758
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
@@ -62,6 +62,8 @@ void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol)
6262
symbol.type=enum_tag_type;
6363
symbol.is_type=false;
6464
symbol.is_macro=true;
65+
symbol.is_file_local = true;
66+
symbol.is_thread_local = true;
6567

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

0 commit comments

Comments
 (0)