diff mbox

[obvious/diagnostics] Honor override_column when printing the caret

Message ID CAESRpQBmeYksSTbBXxi5jUWzdvSFbeLPuaf+LoepwjC2iVsD1g@mail.gmail.com
State New
Headers show

Commit Message

Manuel López-Ibáñez Dec. 2, 2014, 11:18 p.m. UTC
libcpp uses diagnostic->override_column to give a custom column number
to diagnostics. This is taken into account when building the prefix,
but it was missing when placing the caret.

Before:

/home/manuel/override_column.c:1:4: warning: "/*" within comment [-Wcomment]
 /* /* */
 ^

After:

/home/manuel/override_column.c:1:4: warning: "/*" within comment [-Wcomment]
 /* /* */
    ^


Committed as obvious in r218295.


2014-12-03  Manuel López-Ibáñez  <manu@gcc.gnu.org>

    * diagnostic.c (diagnostic_show_locus): Honor override_column when
    placing the caret.

Comments

Dodji Seketeli Dec. 3, 2014, 8:48 a.m. UTC | #1
Manuel López-Ibáñez <lopezibanez@gmail.com> writes:

> libcpp uses diagnostic->override_column to give a custom column number
> to diagnostics. This is taken into account when building the prefix,
> but it was missing when placing the caret.
>
> Before:
>
> /home/manuel/override_column.c:1:4: warning: "/*" within comment [-Wcomment]
>  /* /* */
>  ^
>
> After:
>
> /home/manuel/override_column.c:1:4: warning: "/*" within comment [-Wcomment]
>  /* /* */
>     ^
>
>
> Committed as obvious in r218295.

Thank you for this.

> 2014-12-03  Manuel López-Ibáñez  <manu@gcc.gnu.org>
>
>     * diagnostic.c (diagnostic_show_locus): Honor override_column when
>     placing the caret.
>
> --- gcc/diagnostic.c    (revision 218278)
> +++ gcc/diagnostic.c    (working copy)
> @@ -308,10 +308,12 @@ diagnostic_show_locus (diagnostic_contex
>        || diagnostic->location == context->last_location)
>      return;
>
>    context->last_location = diagnostic->location;
>    s = expand_location_to_spelling_point (diagnostic->location);
> +  if (diagnostic->override_column)
> +    s.column = diagnostic->override_column;
>    line = location_get_source_line (s, &line_width);
>    if (line == NULL || s.column > line_width)
>      return;

Thinking about it again, it would be nice to have a regression test for
this.  At some point, I guess we should do something for regression'
tests about the placement of the caret.  Oh well.

Cheers,
diff mbox

Patch

--- gcc/diagnostic.c    (revision 218278)
+++ gcc/diagnostic.c    (working copy)
@@ -308,10 +308,12 @@  diagnostic_show_locus (diagnostic_contex
       || diagnostic->location == context->last_location)
     return;

   context->last_location = diagnostic->location;
   s = expand_location_to_spelling_point (diagnostic->location);
+  if (diagnostic->override_column)
+    s.column = diagnostic->override_column;
   line = location_get_source_line (s, &line_width);
   if (line == NULL || s.column > line_width)
     return;