diff options
author | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-02-12 19:18:03 +0000 |
---|---|---|
committer | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-02-12 19:18:03 +0000 |
commit | aec1f4bd411b96bd2fb72bf2282be1ebb9687352 (patch) | |
tree | 22a70a51fef5f5d79fbd3d50832a5ca8535979ad /gcc/diagnostic.h | |
parent | 5af71a8fde125f3f02c1eef7105bad5b8f6ebcd8 (diff) | |
download | gcc-aec1f4bd411b96bd2fb72bf2282be1ebb9687352.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233386 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/diagnostic.h')
-rw-r--r-- | gcc/diagnostic.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 7cc5cff185b..017ddcae0bf 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -56,6 +56,10 @@ struct diagnostic_classification_change_t /* Forward declarations. */ typedef void (*diagnostic_starter_fn) (diagnostic_context *, diagnostic_info *); + +typedef void (*diagnostic_start_span_fn) (diagnostic_context *, + expanded_location); + typedef diagnostic_starter_fn diagnostic_finalizer_fn; /* This data structure bundles altogether any information relevant to @@ -148,6 +152,11 @@ struct diagnostic_context */ diagnostic_starter_fn begin_diagnostic; + /* This function is called by diagnostic_show_locus in between + disjoint spans of source code, so that the context can print + something to indicate that a new span of source code has begun. */ + diagnostic_start_span_fn start_span; + /* This function is called after the diagnostic message is printed. */ diagnostic_finalizer_fn end_diagnostic; @@ -296,6 +305,8 @@ extern void diagnostic_append_note (diagnostic_context *, location_t, #endif extern char *diagnostic_build_prefix (diagnostic_context *, const diagnostic_info *); void default_diagnostic_starter (diagnostic_context *, diagnostic_info *); +void default_diagnostic_start_span_fn (diagnostic_context *, + expanded_location); void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *); void diagnostic_set_caret_max_width (diagnostic_context *context, int value); void diagnostic_action_after_output (diagnostic_context *, diagnostic_t); |