In file included from a.h:3:0, from c.cpp:2: Notice there's a 0 on the first line, and no column number on the second line. This affects any inflexible error parsing program. In gcc/diagnostic.c line 245 there's a check for flag_show_column for the first error line but no check for the rest. { map = INCLUDED_FROM (line_table, map); if (flag_show_column) pp_verbatim (context->printer, "In file included from %s:%d:%d", map->to_file, LAST_SOURCE_LINE (map), LAST_SOURCE_COLUMN (map)); else pp_verbatim (context->printer, "In file included from %s:%d", map->to_file, LAST_SOURCE_LINE (map)); while (! MAIN_FILE_P (map)) { map = INCLUDED_FROM (line_table, map); pp_verbatim (context->printer, ",\n from %s:%d", map->to_file, LAST_SOURCE_LINE (map)); } pp_verbatim (context->printer, ":"); pp_newline (context->printer); }
>This affects any inflexible error parsing program. Considering flag_show_column controls the display of column info, it does not say always display it, only when aviable.
(In reply to comment #1) > >This affects any inflexible error parsing program. > > Considering flag_show_column controls the display of column info, it does not > say always display it, only when aviable. > Should be consistent though. Possibly remove the flag_show_column block or add another pp_verbatim LAST_SOURCE_COLUMN in the while loop.
Created attachment 30079 [details] Added LAST_SOURCE_COLUMN in while loop Attached patch adds LAST_SOURCE_COLUMN to pp_verbatim function in the while loop present in diagnostic_report_current_module() to make the output consistent.
Created attachment 33832 [details] adds column to output The currently attached patch doesn't apply cleanly I'm uploading another that does, it's essentially the same patch. Without patch: In file included from /usr/include/c++/4.9.1/iostream:39:0, from test.cxx:1: With patch: In file included from /extra/gcc/bug42014/patched/gcc/pkg/gcc/usr/include/c++/4.9.1/iostream:39:0, from test.cxx:1,0: Which matches the error location.
Patch against the current trunk https://gcc.gnu.org/ml/gcc-patches/2016-06/msg00272.html
Looks like a fix was proposed but the approval was made contingent on getting some a suite issue sorted out. Marcin, did you manage to resolve the test suite issue with David's suggestion? I'm moving the status to New.
Since r11-2092 we don't print the columns at all if the column was 0. So mostly we get: In file included from /usr/include/c++/4.9.1/iostream:39, from test.cxx:1: The code looks like: const char *line_col = maybe_line_and_column (s.line, col); static const char *const msgs[] = { NULL, N_(" from"), N_("In file included from"), /* 2 */ N_(" included from"), N_("In module"), /* 4 */ N_("of module"), N_("In module imported at"), /* 6 */ N_("imported at"), }; unsigned index = (was_module ? 6 : is_module ? 4 : need_inc ? 2 : 0) + !first; pp_verbatim (context->printer, "%s%s %r%s%s%R", first ? "" : was_module ? ", " : ",\n", _(msgs[index]), "locus", s.file, line_col); Where maybe_line_and_column does: static const char * maybe_line_and_column (int line, int col) { static char result[32]; if (line) { size_t l = snprintf (result, sizeof (result), col >= 0 ? ":%d:%d" : ":%d", line, col); gcc_checking_assert (l < sizeof (result)); } else result[0] = 0; return result; }