diff mbox

Print column numbers in inclusion trace consistently.

Message ID 20160603112425.189703-1-marbacz@gmail.com
State New
Headers show

Commit Message

Marcin Baczyński June 3, 2016, 11:24 a.m. UTC
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

Comments

Jeff Law June 22, 2016, 3:09 a.m. UTC | #1
On 06/03/2016 05:24 AM, Marcin Baczyński wrote:
> 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.
The change itself seems reasonable.  You might contact David Malcolm 
(dmalcolm@redhat.com) directly to see if he's got any ideas on how to 
convince the multi-line test to do what you want.  Let's hold off 
installing the fix until we've got the testsuite issue sorted out.

Thanks,
jeff
David Malcolm June 23, 2016, 2:32 p.m. UTC | #2
On Tue, 2016-06-21 at 21:09 -0600, Jeff Law wrote:
> On 06/03/2016 05:24 AM, Marcin Baczyński wrote:
> > 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.
> The change itself seems reasonable.  You might contact David Malcolm 
> (dmalcolm@redhat.com) directly to see if he's got any ideas on how to
> convince the multi-line test to do what you want.  Let's hold off 
> installing the fix until we've got the testsuite issue sorted out.

You could turn up the verbosity level to debug things, by running
something like:

 make check-gcc RUNTESTFLAGS="-v -v -v -v dg.exp=inclusion-trace-column.i"

(multiline.exp prints various things at verbosity level 3 and 4, iirc;
in particular, it can show you the regexp it's looking for).

Maybe a tabs vs spaces issue?

Dave
diff mbox

Patch

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