https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106424
Bug ID: 106424 Summary: __attribute__ unused confuses -Wshadow when placed on internal parameter of fn ptr Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: rusty at rustcorp dot com.au Target Milestone: --- OK, this is a weird one. I have some automated code which adds attributes and it (overzealously) added it to the internal parameter of a callback: void func(char *arg, void (*cb)(char *arg __attribute__((__unused__)))) { } With -Wshadow=local (and -Wshadow) this gives a spurious warning: foo.c:2:28: warning: declaration of ‘arg’ shadows a parameter [-Wshadow] 2 | void (*cb)(char *arg __attribute__((__unused__)))) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ foo.c:1:17: note: shadowed declaration is here 1 | void func(char *arg, | ~~~~~~^~~