GCC supports the -Wshadow command-line option:
-Wshadow
Warn whenever a local variable shadows another local
variable, parameter or global variable or whenever a
built-in function is shadowed.
Currently, enabling this for the PostgreSQL tree produces a lot of
warnings. Would anyone object if I corrected these usages of a
shadowed local variable, and then enabled this warning flag for
standard GCC builds? (as is currently done for -Wmissing-prototypes,
-Wmissing-declarations, and -Wall).
If there are any other GCC warning flags anyone else feels would be
useful, let me know.
-Neil