diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-02-12 19:18:03 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-02-12 19:18:03 +0000 |
commit | 876217ae71cf0b34490f8f53bb2a12d99d8baa7a (patch) | |
tree | 22a70a51fef5f5d79fbd3d50832a5ca8535979ad /gcc/fortran | |
parent | 8dccd19b3be7d3b94c6d3e0cbc7674d12314e909 (diff) | |
download | gcc-876217ae71cf0b34490f8f53bb2a12d99d8baa7a.zip gcc-876217ae71cf0b34490f8f53bb2a12d99d8baa7a.tar.gz gcc-876217ae71cf0b34490f8f53bb2a12d99d8baa7a.tar.bz2 |
PR other/69554: avoid excessive source printing for widely-separated locations
gcc/ChangeLog:
PR other/69554
* diagnostic-show-locus.c (struct line_span): New struct.
(layout::get_first_line): Delete.
(layout::get_last_line): Delete.
(layout::get_num_line_spans): New member function.
(layout::get_line_span): Likewise.
(layout::print_heading_for_line_span_index_p): Likewise.
(layout::get_expanded_location): Likewise.
(layout::calculate_line_spans): Likewise.
(layout::m_first_line): Delete.
(layout::m_last_line): Delete.
(layout::m_line_spans): New field.
(layout::layout): Update comment. Replace m_first_line and
m_last_line with m_line_spans, replacing their initialization
with a call to calculate_line_spans.
(diagnostic_show_locus): When printing source lines and
annotations, rather than looping over a single span
of lines, instead loop over each line_span within
the layout, with an inner loop over the lines within them.
Call the context's start_span callback when changing line spans.
* diagnostic.c (diagnostic_initialize): Initialize start_span.
(diagnostic_build_prefix): Break out the building of the location
part of the string into...
(diagnostic_get_location_text): ...this new function, rewriting
it from nested ternary expressions to a sequence of "if"
statements.
(default_diagnostic_start_span_fn): New function.
* diagnostic.h (diagnostic_start_span_fn): New typedef.
(diagnostic_context::start_span): New field.
(default_diagnostic_start_span_fn): New prototype.
gcc/fortran/ChangeLog:
PR other/69554
* error.c (gfc_diagnostic_start_span): New function.
(gfc_diagnostics_init): Initialize global_dc's start_span.
gcc/testsuite/ChangeLog:
PR other/69554
* gcc.dg/pr69554-1.c: New test.
* gfortran.dg/pr69554-1.F90: New test.
* gfortran.dg/pr69554-2.F90: New test.
* lib/gcc-dg.exp (proc dg-locus): New function.
* lib/gfortran-dg.exp (proc gfortran-dg-test): Update comment to
distinguish between the caret-printing and non-caret-printing
cases. If caret-printing has been explicitly enabled, bail out
without attempting to fix up the output.
From-SVN: r233386
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/error.c | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 77a08c4..de669e0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-02-12 David Malcolm <dmalcolm@redhat.com> + + PR other/69554 + * error.c (gfc_diagnostic_start_span): New function. + (gfc_diagnostics_init): Initialize global_dc's start_span. + 2016-02-11 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/69296 diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c index e7f4ba7..003702b 100644 --- a/gcc/fortran/error.c +++ b/gcc/fortran/error.c @@ -1103,6 +1103,20 @@ gfc_diagnostic_starter (diagnostic_context *context, } static void +gfc_diagnostic_start_span (diagnostic_context *context, + expanded_location exploc) +{ + char *locus_prefix; + locus_prefix = gfc_diagnostic_build_locus_prefix (context, exploc); + pp_verbatim (context->printer, locus_prefix); + free (locus_prefix); + pp_newline (context->printer); + /* Fortran uses an empty line between locus and caret line. */ + pp_newline (context->printer); +} + + +static void gfc_diagnostic_finalizer (diagnostic_context *context, diagnostic_info *diagnostic ATTRIBUTE_UNUSED) { @@ -1426,6 +1440,7 @@ void gfc_diagnostics_init (void) { diagnostic_starter (global_dc) = gfc_diagnostic_starter; + global_dc->start_span = gfc_diagnostic_start_span; diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer; diagnostic_format_decoder (global_dc) = gfc_format_decoder; global_dc->caret_chars[0] = '1'; |