As seen here, the following is valid C code:
int test = 10;
if (true) {
int test = 10;
}
I'm wondering if there's a flag to warn in cases like that, where the redefinition is identical.
There is: -Wshadow=local
. Passing in a different value (instead of "local") also allows more precise control over which identifiers can and can't be shadowed.
It checks whether the name is the same, which is a good enough approximation.