Marek Polacek <pola...@redhat.com> a écrit:

> On Wed, Aug 13, 2014 at 09:03:37PM +0200, Manuel López-Ibáñez wrote:
>> I don't think this is the right fix. The problem is that we are trying
>> to print the caret in a column that is larger than the line_width. We
>> do this because the file given by the line directive has nothing to do
>> with the actual code we are parsing. I think in that case it is ok to
>> just give up and not print a caret. So something like:
>> 
>> @@ -300,11 +299,11 @@ diagnostic_show_locus (diagnostic_contex
>>      return;
>> 
>>    context->last_location = diagnostic->location;
>>    s = expand_location_to_spelling_point (diagnostic->location);
>>    line = location_get_source_line (s, &line_width);
>> -  if (line == NULL)
>> +  if (line == NULL || s.column > line_width)
>>      return;
>> 
>>    max_width = context->caret_max_width;
>>    line = adjust_line (line, line_width, max_width, &(s.column));
>> 
>> Nonetheless, perhaps in addition adjust_line should have
>> gcc_checking_assert(line_width >= column).
>
> Yea, I think this would be much better, thanks.  Done in the
> following.

Yes, I agree with this as well.

> Bootstrapped/regtested on x86_64-linux, ok for trunk?

Yes, this is OK to me.

Thank you for looking into this.

Cheers.

-- 
                Dodji

Reply via email to