aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2018-08-16 22:28:19 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2018-08-16 22:28:19 +0000
commit5218dafdc219eb49a0b8d776b99fd7a7afb5be0b (patch)
tree971a758dacf375f998eb1413885623dcb833a42b
parent4416420e14b7505355c2318a6bd09ae073551d36 (diff)
downloadgcc-5218dafdc219eb49a0b8d776b99fd7a7afb5be0b.zip
gcc-5218dafdc219eb49a0b8d776b99fd7a7afb5be0b.tar.gz
gcc-5218dafdc219eb49a0b8d776b99fd7a7afb5be0b.tar.bz2
diagnostics: tweak to line-insertion fix-it hints with line-numbering
This commit slightly tweaks line-insertion fix-it hints, so that with line-numbering, rather than e.g.: 99 | x = a; |+ break; 110 | case 'b': | ^~~~~~~~ we fill the margin with "+": 99 | x = a; +++ |+ break; 110 | case 'b': | ^~~~~~~~ to emphasize that this is a suggested new line, rather than the user's source. gcc/ChangeLog: * diagnostic-show-locus.c (layout::start_annotation_line): Add "margin_char" parameter, defaulting to space. Use it in place of pp_space for the initial part of the margin. (layout::print_leading_fixits): Use '+' when filling the margin of line-insertion fix-it hints. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c (test_fixit_insert_newline): Update expected output to show '+' characters in margin of line-insertion fix-it hint. From-SVN: r263605
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/diagnostic-show-locus.c8
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c2
4 files changed, 19 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 38ef1fd..c776f6d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2018-08-16 David Malcolm <dmalcolm@redhat.com>
+
+ * diagnostic-show-locus.c (layout::start_annotation_line): Add
+ "margin_char" parameter, defaulting to space. Use it in place
+ of pp_space for the initial part of the margin.
+ (layout::print_leading_fixits): Use '+' when filling the margin
+ of line-insertion fix-it hints.
+
2018-08-16 Segher Boessenkool <segher@kernel.crashing.org>
* config/rs6000/rs6000.md (two unnamed define_insn and define_split):
diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c
index c9edaab..a759826 100644
--- a/gcc/diagnostic-show-locus.c
+++ b/gcc/diagnostic-show-locus.c
@@ -253,7 +253,7 @@ class layout
void print_source_line (linenum_type row, const char *line, int line_width,
line_bounds *lbounds_out);
bool should_print_annotation_line_p (linenum_type row) const;
- void start_annotation_line () const;
+ void start_annotation_line (char margin_char = ' ') const;
void print_annotation_line (linenum_type row, const line_bounds lbounds);
void print_any_labels (linenum_type row);
void print_trailing_fixits (linenum_type row);
@@ -1330,12 +1330,12 @@ layout::should_print_annotation_line_p (linenum_type row) const
margin, which is empty for annotation lines. Otherwise, do nothing. */
void
-layout::start_annotation_line () const
+layout::start_annotation_line (char margin_char) const
{
if (m_show_line_numbers_p)
{
for (int i = 0; i < m_linenum_width; i++)
- pp_space (m_pp);
+ pp_character (m_pp, margin_char);
pp_string (m_pp, " |");
}
}
@@ -1587,7 +1587,7 @@ layout::print_leading_fixits (linenum_type row)
helps them stand out from each other, and from
the surrounding text. */
m_colorizer.set_normal_text ();
- start_annotation_line ();
+ start_annotation_line ('+');
pp_character (m_pp, '+');
m_colorizer.set_fixit_insert ();
/* Print all but the trailing newline of the fix-it hint.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0753e9c..978bd8f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2018-08-16 David Malcolm <dmalcolm@redhat.com>
+
+ * gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c
+ (test_fixit_insert_newline): Update expected output to show '+'
+ characters in margin of line-insertion fix-it hint.
+
2018-08-16 Nathan Sidwell <nathan@acm.org>
* gcc.dg/cpp/macsyntx.c: Adjust expected errors.
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c
index 89213eb..f2bbc58 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c
@@ -111,7 +111,7 @@ void test_fixit_insert_newline (void)
x = b;
}
/* { dg-begin-multiline-output "" }
- |+ break;
++++ |+ break;
110 | case 'b':
| ^~~~~~~~
{ dg-end-multiline-output "" } */