https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91765
Bug ID: 91765 Summary: -Wredundant-decls conflicts with __attribute__((alias)) Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: rth at gcc dot gnu.org Target Milestone: --- /* Header file */ extern int bar; /* Source file */ static int foo; extern int bar __attribute__((alias("foo"))); ------ For this test case, "gcc -c -Wredundant-decls z.c" produces z.c:6:12: warning: redundant redeclaration of ‘bar’ [-Wredundant-decls] 6 | extern int bar __attribute__((alias("foo"))); | ^~~ z.c:2:12: note: previous declaration of ‘bar’ was here 2 | extern int bar; | ^~~ However, the alias line is not a redundant decl, but rather the actual definition of the symbol "bar". The syntax of the alias, for whatever reason, requires the use of the extern keyword. Remove the extern from the alias and we get z.c:6:5: error: ‘bar’ defined both normally and as ‘alias’ attribute 6 | int bar __attribute__((alias("foo"))); | ^~~ This also seems like a bug, but it's probably years too late to change the syntax of the definition of aliases.