https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65466
Bug ID: 65466 Summary: Unnecessary source line output for "note: each undeclared identifier is reported only once" Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: achurch+gcc at achurch dot org For the first undeclared identifier found in a source file, GCC outputs an additional diagnostic, "note: each undeclared identifier is reported only once for each function it appears in", and then (assuming no -fno-diagnostics-show-caret) displays the source line and location of the undeclared identifier. The note itself is fine, but the source location only clutters up the output since it was already displayed for the actual warning. This is exacerbated if the undeclared identifier was used in a macro, since the macro expansion is also printed twice (as in the example below). It seems to me it would make more sense to either suppress the source line display and macro expansion for the "note: each undeclared..." diagnostic, or merge that text into the warning text for the first instance of the warning, perhaps: "'bar' undeclared (first use in this function; each undeclared identifier is reported only once for each function it appears in)". $ cat foo.c #define FOO(x) x int foo(void) {return FOO(bar);} $ gcc-4.9.2 -c foo.c foo.c: In function 'foo': foo.c:2:27: error: 'bar' undeclared (first use in this function) int foo(void) {return FOO(bar);} ^ foo.c:1:16: note: in definition of macro 'FOO' #define FOO(x) x ^ foo.c:2:27: note: each undeclared identifier is reported only once for each function it appears in int foo(void) {return FOO(bar);} ^ foo.c:1:16: note: in definition of macro 'FOO' #define FOO(x) x ^