Message ID | 20230921121312.1301864-1-armbru@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Markus Armbruster <armbru@redhat.com> writes: > Local variables shadowing other local variables or parameters make the > code needlessly hard to understand. Bugs love to hide in such code. > Evidence: PATCH 1. > > Enabling -Wshadow would prevent bugs like this one. But we'd have to > clean up all the offenders first. We got a lot of them. > > Enabling -Wshadow=local should be less work for almost as much gain. > I took a stab at it. There's a small, exciting part, and a large, > boring part. > > The exciting part is dark preprocessor sorcery to let us nest macro > calls without shadowing: PATCH 7. [...] Queued.
diff --git a/meson.build b/meson.build index 98e68ef0b1..9fc4c7ac9d 100644 --- a/meson.build +++ b/meson.build @@ -466,6 +466,9 @@ warn_flags = [ '-Wno-tautological-type-limit-compare', '-Wno-psabi', '-Wno-gnu-variable-sized-type-not-at-end', + '-Wshadow=local', + '-Wno-error=shadow=local', + '-Wno-error=shadow=compatible-local', ] if targetos != 'darwin'