This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] v3 of diagnostic_show_locus and rich_location (was Re: [PATCH 2/5] Reimplement diagnostic_show_locus, introducing rich_location classes (v2))
- From: Manuel LÃpez-IbÃÃez <lopezibanez at gmail dot com>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: Dodji Seketeli <dodji at seketeli dot org>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, Tobias Burnus <burnus at net-b dot de>, "Joseph S. Myers" <joseph at codesourcery dot com>, Mike Stump <mikestump at comcast dot net>, Rainer Orth <ro at cebitec dot uni-bielefeld dot de>
- Date: Sat, 26 Sep 2015 00:09:27 +0200
- Subject: Re: [PATCH] v3 of diagnostic_show_locus and rich_location (was Re: [PATCH 2/5] Reimplement diagnostic_show_locus, introducing rich_location classes (v2))
- Authentication-results: sourceware.org; auth=none
- References: <1442957171-22904-1-git-send-email-dmalcolm at redhat dot com> <1442957171-22904-3-git-send-email-dmalcolm at redhat dot com> <86h9miswzc dot fsf at seketeli dot org> <1443211881 dot 30732 dot 121 dot camel at surprise> <CAESRpQCFq1rNnJxPkQuZ=Y_vYgqdFXLSDmcz2-gPLt0CX9yxxA at mail dot gmail dot com> <CAESRpQCbZPa8cOYhyJK_u1+ftGuy1kUa2LdtmO7yGfzprSxn0A at mail dot gmail dot com> <CAESRpQArp2fV6miUz8pzMHs6J5mP4X8BWRA3RMFCwrsULMRJYQ at mail dot gmail dot com> <1443216287 dot 30732 dot 154 dot camel at surprise>
On 25 September 2015 at 23:24, David Malcolm <dmalcolm@redhat.com> wrote:
> On Fri, 2015-09-25 at 23:13 +0200, Manuel LÃpez-IbÃÃez wrote:
>> + If SHOW_CARET_P is true, then the range should be rendered with
>> + a caret at its starting location. This
>> + is for use by the Fortran frontend, for implementing the
>> + "%C" and "%L" format codes. */
>> +
>> +void
>> +rich_location::set_range (unsigned int idx, source_range src_range,
>> + bool show_caret_p, bool overwrite_loc_p)
>>
>> I do not understand when is this show_caret_p used by Fortran given
>> the diagnostic_show_locus code mentioned earlier.
[...]
> rich_location::set_range exists to ensure that the %C and %L codes used
> by Fortran (and "+" in the C family of FEs) can write back into the
> rich_location instance, faithfully emulating the old code that wrote
> back to
> struct text_info's:
> location_t locations[MAX_LOCATIONS_PER_MESSAGE];
Why Fortran cannot use text->set_location like the other FEs? This way
you do not need set_range at all. In fact, you do:
+ source_range range
+ = source_range::from_location (
+ linemap_position_for_loc_and_offset (line_table,
+ loc->lb->location,
+ offset));
+ text->set_range (loc_num, range, true);
But I guess this doesn't actually create a range like ^~~~ but as single ^.
The other issue that confuses me is that show_caret_p is always true
when reaching this function via the pretty-printer. Thus, show_caret_p
is also used by C/C++. In fact, I'm not sure when it can be false.
Cheers,
Manuel.