Skip to content

Commit e03011e

Browse files
committed
C front-end: do not warn when re-initialising a variable with the same value
There is no surprising behaviour when all initialisers are the same.
1 parent 4a1a325 commit e03011e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/ansi-c/c_typecheck_base.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,18 +573,15 @@ void c_typecheck_baset::typecheck_redefinition_non_type(
573573
// see if we already have one
574574
if(old_symbol.value.is_not_nil())
575575
{
576-
if(
577-
new_symbol.is_macro && final_new.id() == ID_c_enum &&
578-
old_symbol.value.is_constant() && new_symbol.value.is_constant() &&
579-
old_symbol.value.get(ID_value) == new_symbol.value.get(ID_value))
576+
if(old_symbol.value == new_symbol.value)
580577
{
581578
// ignore
582579
}
583580
else
584581
{
585582
warning().source_location = new_symbol.value.find_source_location();
586583
warning() << "symbol '" << new_symbol.display_name()
587-
<< "' already has an initial value" << eom;
584+
<< "' already has a different initial value" << eom;
588585
}
589586
}
590587
else

0 commit comments

Comments
 (0)