Hi,
the patch below fixes PR/42014. Although the fix itself seems easy enough,
I have a problem with the test. Is there a way to match the output before
the "warning:" line? dg-{begin,end}-multiline-output doesn't do the job, or
at least I don't know how to convince it.

Bootstrapped on x86_64 linux.

Thanks,
Marcin


gcc/ChangeLog:

   PR/42014

   * diagnostic.c (diagnostic_report_current_module): Print column numbers
    for all mentioned files if context->show_column.

gcc/testsuite/ChangeLog:

   PR/42014

   * gcc.dg/inclusion-trace-column.i: New test.
---
 gcc/diagnostic.c                              | 12 +++++++++---
 gcc/testsuite/gcc.dg/inclusion-trace-column.i | 16 ++++++++++++++++
 2 files changed, 25 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/inclusion-trace-column.i

diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 8106172..05037ba 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -537,9 +537,15 @@ diagnostic_report_current_module (diagnostic_context 
*context, location_t where)
          while (! MAIN_FILE_P (map))
            {
              map = INCLUDED_FROM (line_table, map);
-             pp_verbatim (context->printer,
-                          ",\n                 from %r%s:%d%R", "locus",
-                          LINEMAP_FILE (map), LAST_SOURCE_LINE (map));
+              if (context->show_column)
+                pp_verbatim (context->printer,
+                             ",\n                 from %r%s:%d:%d%R", "locus",
+                             LINEMAP_FILE (map),
+                             LAST_SOURCE_LINE (map), LAST_SOURCE_COLUMN (map));
+              else
+                pp_verbatim (context->printer,
+                             ",\n                 from %r%s:%d%R", "locus",
+                             LINEMAP_FILE (map), LAST_SOURCE_LINE (map));
            }
          pp_verbatim (context->printer, ":");
          pp_newline (context->printer);
diff --git a/gcc/testsuite/gcc.dg/inclusion-trace-column.i 
b/gcc/testsuite/gcc.dg/inclusion-trace-column.i
new file mode 100644
index 0000000..1fb8923
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/inclusion-trace-column.i
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-fshow-column -Wreturn-type" } */
+/* { dg-begin-multiline-output "" }
+In file included from b.h:1:0,
+                 from a.h:1:0,
+                 from t.c:1:0:
+   { dg-end-multiline-output "" } */
+/* PR 42014 */
+# 1 "t.c"
+# 1 "a.h" 1
+# 1 "b.h" 1
+# 1 "c.h" 1
+double f () {}  /* { dg-warning "reaches end" "no return" { target *-*-* } 1 } 
*/
+# 1 "b.h" 2
+# 1 "a.h" 2
+# 1 "t.c" 2
-- 
2.8.3

Reply via email to