aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/lib/gcc-dg.exp
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-02-12 19:18:03 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-02-12 19:18:03 +0000
commit876217ae71cf0b34490f8f53bb2a12d99d8baa7a (patch)
tree22a70a51fef5f5d79fbd3d50832a5ca8535979ad /gcc/testsuite/lib/gcc-dg.exp
parent8dccd19b3be7d3b94c6d3e0cbc7674d12314e909 (diff)
downloadgcc-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/testsuite/lib/gcc-dg.exp')
-rw-r--r--gcc/testsuite/lib/gcc-dg.exp27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 3dd8564..b732b54 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -988,6 +988,33 @@ proc dg-message { args } {
process-message saved-dg-warning "" $args
}
+# Look for a location marker of the form
+# file:line:column:
+# with no extra text (e.g. a line-span separator).
+
+proc dg-locus { args } {
+ upvar dg-messages dg-messages
+
+ # Process the dg- directive, including adding the regular expression
+ # to the new message entry in dg-messages.
+ set msgcnt [llength ${dg-messages}]
+ eval saved-dg-warning $args
+
+ # If the target expression wasn't satisfied there is no new message.
+ if { [llength ${dg-messages}] == $msgcnt } {
+ return;
+ }
+
+ # Get the entry for the new message. Prepend the message prefix to
+ # the regular expression and make it match a single line.
+ set newentry [lindex ${dg-messages} end]
+ set expmsg [lindex $newentry 2]
+
+ set newentry [lreplace $newentry 2 2 $expmsg]
+ set dg-messages [lreplace ${dg-messages} end end $newentry]
+ verbose "process-message:\n${dg-messages}" 2
+}
+
# Check the existence of a gdb in the path, and return true if there
# is one.
#