Skip to content

C front-end: do not warn when re-initialising a variable with the same value #8695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/ansi-c/c_typecheck_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,18 +573,15 @@ void c_typecheck_baset::typecheck_redefinition_non_type(
// see if we already have one
if(old_symbol.value.is_not_nil())
{
if(
new_symbol.is_macro && final_new.id() == ID_c_enum &&
old_symbol.value.is_constant() && new_symbol.value.is_constant() &&
old_symbol.value.get(ID_value) == new_symbol.value.get(ID_value))
if(old_symbol.value == new_symbol.value)
{
// ignore
}
else
{
warning().source_location = new_symbol.value.find_source_location();
warning() << "symbol '" << new_symbol.display_name()
<< "' already has an initial value" << eom;
<< "' already has a different initial value" << eom;
}
}
else
Expand Down
Loading