On 25 September 2015 at 22:18, Manuel López-Ibáñez <lopeziba...@gmail.com> wrote: > On 25 September 2015 at 22:11, David Malcolm <dmalc...@redhat.com> wrote:
context->last_location = diagnostic_location (diagnostic, 0); - expanded_location s0 = diagnostic_expand_location (diagnostic, 0); - expanded_location s1 = { }; - /* Zero-initialized. This is checked later by diagnostic_print_caret_line. */ - if (diagnostic_location (diagnostic, 1) > BUILTINS_LOCATION) - s1 = diagnostic_expand_location (diagnostic, 1); + if (context->frontend_calls_diagnostic_print_caret_line_p) + { + /* The GCC < 6 routine. */ + expanded_location s0 = diagnostic_expand_location (diagnostic, 0); + expanded_location s1 = { }; + /* Zero-initialized. This is checked later by + diagnostic_print_caret_line. */ + + if (diagnostic_num_locations (diagnostic) >= 2) + s1 = diagnostic->message.m_richloc->get_range (1)->m_start; - diagnostic_print_caret_line (context, s0, s1, - context->caret_chars[0], - context->caret_chars[1]); + diagnostic_print_caret_line (context, s0, s1, + context->caret_chars[0], + context->caret_chars[1]); + } + else + /* The GCC >= 6 routine. */ + diagnostic_print_ranges (context, diagnostic); } I haven't had time to look at the patch in detail, so please excuse me if this is answered elsewhere. Why do you need this hack? The whole point of moving Fortran to the common machinery is to not have this duplication. Can't the new code print one caret without ranges ever? Something like: error: expected ';' } ^ If it can, then the function responsible for doing that can be called by Fortran and it should replace diagnostic_print_caret_line. Or is it that the new diagnostic_print_ranges cannot print multiple carets in the same line? Like this error: error at (1) and (2) adfadfafd asdfdaffa 1 2 If this is the case, this is a missing functionality that diagnostic_print_caret_line already has and that was ready to be used in C/C++. See example at (O) here: https://gcc.gnu.org/wiki/Better_Diagnostics In my mind, it should be possible for Fortran to pass to the diagnostics machinery two locations with range width 1 (or 0, depending how you want to represent a range that covers exactly one char) and get a caret line like the example above. Why is this not possible? Cheers, Manuel.