On Tue, 2016-08-30 at 17:08 +0530, Prathamesh Kulkarni wrote:
> On 30 August 2016 at 05:34, David Malcolm <dmalc...@redhat.com>
> wrote:
> > On Mon, 2016-08-29 at 20:01 -0400, David Malcolm wrote:
> > > On Mon, 2016-08-29 at 19:55 -0400, David Malcolm wrote:
> > > [...]
> > > > Assuming you have the location_t values available, you can
> > > > create a
> > > > rich_location for the primary range, and then add secondary
> > > > ranges
> > > > like
> > > > this:
> > > > 
> > > >   rich_location richloc (loc_of_arg1);
> > > 
> > > Oops, the above should be:
> > > 
> > >     rich_location richloc (line_table, loc_of_arg1);
> > > 
> > > or:
> > > 
> > >     gcc_rich_location (loc_of_arg1);
> > and this should be:
> > 
> >      gcc_rich_location richloc (loc_of_arg1);
> > > which does the same thing (#include "gcc-rich-location.h").
> > 
> > Clearly I need to sleep :)
> Hi David,
> Thanks for the suggestions. I can now see multiple source ranges for
> pr35503-2.c (included in patch).
> Output shows: http://pastebin.com/FNAVDU8A
> (Posted pastebin link to avoid mangling by the mailer)

The underlines look great, thanks for working on this.

> However the test for underline fails:
> FAIL: c-c++-common/pr35503-2.c  -Wc++-compat   expected multiline
> pattern lines 12-13 not found: "\s*f \(&alpha, &beta, &alpha,
> &alpha\);.*\n      \^~~~~~         ~~~~~~  ~~~~~~ .*\n"
> I have attached gcc.log for the test-case. Presumably I have written
> the test-case incorrectly.
> Could you please have a look at it ?

(I hope this doesn't get too badly mangled by Evolution...)

I think you have an extra trailing space on the line containing the
expected underlines within the multiline directive:

+/* { dg-begin-multiline-output "" }
+   f (&alpha, &beta, &alpha, &alpha);
+      ^~~~~~         ~~~~~~  ~~~~~~ 
                                    ^ EXTRA SPACE HERE
+   { dg-end-multiline-output "" } */
+}

as the actual output is:

   f (&alpha, &beta, &alpha, &alpha);
      ^~~~~~         ~~~~~~  ~~~~~~
                                  ^ LINE ENDS HERE, with no trailing
space present

This space shows up in the error here:

FAIL: c-c++-common/pr35503-2.c  -Wc++-compat   expected multiline
pattern lines 12-13 not found: "\s*f \(&alpha, &beta, &alpha,
&alpha\);.*\n      \^~~~~~         ~~~~~~  ~~~~~~ .*\n"
                                                 ^ EXTRA SPACE

BTW, the .* at the end of the pattern means it's ok to have additional
material in the actual output that isn't matched (e.g. for comments
containing dg- directives [1] ) but it doesn't work the other way
around: all of the text within the dg-begin/end-multiline directives
has to be in the actual output.


[1] so you can have e.g.:

  f (&alpha, &beta, &alpha, &alpha); /* { dg-warning "passing argument 1 to 
restrict-qualified parameter aliases with arguments 3, 4" } */

and:

/* { dg-begin-multiline-output "" }
   f (&alpha, &beta, &alpha, &alpha);
      ^~~~~~         ~~~~~~  ~~~~~~
   { dg-end-multiline-output "" } */

where the actual output will look like:

pr35503-2.c:8:6: warning: passing argument 1 to restrict-qualified parameter 
aliases with arguments 3, 4 [-Wrestrict]
   f (&alpha, &beta, &alpha, &alpha); /* { dg-warning "passing argument 1 to 
restrict-qualified parameter aliases with arguments 3, 4" } */
     ^~~~~~         ~~~~~~  ~~~~~~

and you can omit the copy of the dg-warning directive in the expected
multiline output (which would otherwise totally confuse DejaGnu).
Doing so avoids having to specify the line number.

> Thanks,
> Prathamesh
> > 
> > > >   richloc.add_range (loc_of_arg3, false);  /* false here =
> > > > don't
> > > > draw
> > > > a
> > > > caret, just the underline */
> > > >   richloc.add_range (loc_of_arg4, false);
> > > >   warning_at_rich_loc (&richloc, OPT_Wrestrict, etc...
> > > > 
> > > > See line-map.h for more information on rich_location.
> > > 
> > > [...]

Reply via email to