aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ada/gcc-interface/misc.cc2
-rw-r--r--gcc/analyzer/program-point.cc4
-rw-r--r--gcc/c-family/c-common.cc2
-rw-r--r--gcc/c-family/c-opts.cc2
-rw-r--r--gcc/diagnostic-show-locus.cc93
-rw-r--r--gcc/diagnostic.cc16
-rw-r--r--gcc/diagnostic.h73
-rw-r--r--gcc/fortran/error.cc10
-rw-r--r--gcc/opts.cc8
-rw-r--r--gcc/selftest-diagnostic.cc8
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c26
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c2
-rw-r--r--gcc/toplev.cc8
-rw-r--r--gcc/tree-diagnostic-path.cc2
18 files changed, 140 insertions, 124 deletions
diff --git a/gcc/ada/gcc-interface/misc.cc b/gcc/ada/gcc-interface/misc.cc
index 3b21bf5..269c15e 100644
--- a/gcc/ada/gcc-interface/misc.cc
+++ b/gcc/ada/gcc-interface/misc.cc
@@ -269,7 +269,7 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
/* No caret by default for Ada. */
if (!OPTION_SET_P (flag_diagnostics_show_caret))
- global_dc->show_caret = false;
+ global_dc->m_source_printing.enabled = false;
/* Copy global settings to local versions. */
gnat_encodings = global_options.x_gnat_encodings;
diff --git a/gcc/analyzer/program-point.cc b/gcc/analyzer/program-point.cc
index d7db2f5..914d49f 100644
--- a/gcc/analyzer/program-point.cc
+++ b/gcc/analyzer/program-point.cc
@@ -256,8 +256,8 @@ public:
debug_diagnostic_context ()
{
diagnostic_initialize (this, 0);
- show_line_numbers_p = true;
- show_caret = true;
+ m_source_printing.show_line_numbers_p = true;
+ m_source_printing.enabled = true;
}
~debug_diagnostic_context ()
{
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index aae5726..f044db5 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -9569,7 +9569,7 @@ maybe_add_include_fixit (rich_location *richloc, const char *header,
richloc->add_fixit_insert_before (include_insert_loc, text);
free (text);
- if (override_location && global_dc->show_caret)
+ if (override_location && global_dc->m_source_printing.enabled)
{
/* Replace the primary location with that of the insertion point for the
fix-it hint.
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index fe2d143..ce2e021 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -272,7 +272,7 @@ c_common_init_options (unsigned int decoded_options_count,
if (c_dialect_cxx ())
set_std_cxx17 (/*ISO*/false);
- global_dc->colorize_source_p = true;
+ global_dc->m_source_printing.colorize_source_p = true;
}
/* Handle switch SCODE with argument ARG. VALUE is true, unless no-
diff --git a/gcc/diagnostic-show-locus.cc b/gcc/diagnostic-show-locus.cc
index 31ef851..0778223 100644
--- a/gcc/diagnostic-show-locus.cc
+++ b/gcc/diagnostic-show-locus.cc
@@ -1193,9 +1193,9 @@ layout::layout (diagnostic_context * context,
m_exploc (richloc->get_expanded_location (0), m_policy,
LOCATION_ASPECT_CARET),
m_colorizer (context, diagnostic_kind),
- m_colorize_source_p (context->colorize_source_p),
- m_show_labels_p (context->show_labels_p),
- m_show_line_numbers_p (context->show_line_numbers_p),
+ m_colorize_source_p (context->m_source_printing.colorize_source_p),
+ m_show_labels_p (context->m_source_printing.show_labels_p),
+ m_show_line_numbers_p (context->m_source_printing.show_line_numbers_p),
m_diagnostic_path_p (diagnostic_kind == DK_DIAGNOSTIC_PATH),
m_layout_ranges (richloc->get_num_locations ()),
m_fixit_hints (richloc->get_num_fixit_hints ()),
@@ -1229,8 +1229,8 @@ layout::layout (diagnostic_context * context,
calculate_linenum_width ();
calculate_x_offset_display ();
- if (context->show_ruler_p)
- show_ruler (m_x_offset_display + m_context->caret_max_width);
+ if (context->m_source_printing.show_ruler_p)
+ show_ruler (m_x_offset_display + m_context->m_source_printing.max_width);
}
@@ -1595,7 +1595,8 @@ layout::calculate_linenum_width ()
m_linenum_width = MAX (m_linenum_width, 3);
/* If there's a minimum margin width, apply it (subtracting 1 for the space
after the line number. */
- m_linenum_width = MAX (m_linenum_width, m_context->min_margin_width - 1);
+ m_linenum_width = MAX (m_linenum_width,
+ m_context->m_source_printing.min_margin_width - 1);
}
/* Calculate m_x_offset_display, which improves readability in case the source
@@ -1609,7 +1610,7 @@ layout::calculate_x_offset_display ()
{
m_x_offset_display = 0;
- const int max_width = m_context->caret_max_width;
+ const int max_width = m_context->m_source_printing.max_width;
if (!max_width)
{
/* Nothing to do, the width is not capped. */
@@ -1851,7 +1852,8 @@ layout::print_annotation_line (linenum_type row, const line_bounds lbounds)
/* Draw the caret. */
char caret_char;
if (state.range_idx < rich_location::STATICALLY_ALLOCATED_RANGES)
- caret_char = m_context->caret_chars[state.range_idx];
+ caret_char
+ = m_context->m_source_printing.caret_chars[state.range_idx];
else
caret_char = '^';
pp_character (m_pp, caret_char);
@@ -2838,7 +2840,7 @@ diagnostic_show_locus (diagnostic_context * context,
{
location_t loc = richloc->get_loc ();
/* Do nothing if source-printing has been disabled. */
- if (!context->show_caret)
+ if (!context->m_source_printing.enabled)
return;
/* Don't attempt to print source for UNKNOWN_LOCATION and for builtins. */
@@ -2860,7 +2862,7 @@ diagnostic_show_locus (diagnostic_context * context,
line_span_idx++)
{
const line_span *line_span = layout.get_line_span (line_span_idx);
- if (context->show_line_numbers_p)
+ if (context->m_source_printing.show_line_numbers_p)
{
/* With line numbers, we should show whenever the line-numbering
"jumps". */
@@ -2959,11 +2961,11 @@ test_offset_impl (int caret_byte_col, int max_width,
int left_margin = test_left_margin)
{
test_diagnostic_context dc;
- dc.caret_max_width = max_width;
+ dc.m_source_printing.max_width = max_width;
/* diagnostic_context::min_margin_width sets the minimum space reserved for
the line number plus one space after. */
- dc.min_margin_width = left_margin - test_linenum_sep + 1;
- dc.show_line_numbers_p = true;
+ dc.m_source_printing.min_margin_width = left_margin - test_linenum_sep + 1;
+ dc.m_source_printing.show_line_numbers_p = true;
rich_location richloc (line_table,
linemap_position_for_column (line_table,
caret_byte_col));
@@ -3074,10 +3076,11 @@ test_layout_x_offset_display_utf8 (const line_table_case &case_)
/* Test that the source line is offset as expected when printed. */
{
test_diagnostic_context dc;
- dc.caret_max_width = small_width - 6;
- dc.min_margin_width = test_left_margin - test_linenum_sep + 1;
- dc.show_line_numbers_p = true;
- dc.show_ruler_p = true;
+ dc.m_source_printing.max_width = small_width - 6;
+ dc.m_source_printing.min_margin_width
+ = test_left_margin - test_linenum_sep + 1;
+ dc.m_source_printing.show_line_numbers_p = true;
+ dc.m_source_printing.show_ruler_p = true;
rich_location richloc (line_table,
linemap_position_for_column (line_table,
emoji_col));
@@ -3098,10 +3101,11 @@ test_layout_x_offset_display_utf8 (const line_table_case &case_)
it with a padding space in this case. */
{
test_diagnostic_context dc;
- dc.caret_max_width = small_width - 5;
- dc.min_margin_width = test_left_margin - test_linenum_sep + 1;
- dc.show_line_numbers_p = true;
- dc.show_ruler_p = true;
+ dc.m_source_printing.max_width = small_width - 5;
+ dc.m_source_printing.min_margin_width
+ = test_left_margin - test_linenum_sep + 1;
+ dc.m_source_printing.show_line_numbers_p = true;
+ dc.m_source_printing.show_ruler_p = true;
rich_location richloc (line_table,
linemap_position_for_column (line_table,
emoji_col + 2));
@@ -3201,9 +3205,10 @@ test_layout_x_offset_display_tab (const line_table_case &case_)
test_diagnostic_context dc;
dc.tabstop = tabstop;
static const int small_width = 24;
- dc.caret_max_width = small_width - 4;
- dc.min_margin_width = test_left_margin - test_linenum_sep + 1;
- dc.show_line_numbers_p = true;
+ dc.m_source_printing.max_width = small_width - 4;
+ dc.m_source_printing.min_margin_width
+ = test_left_margin - test_linenum_sep + 1;
+ dc.m_source_printing.show_line_numbers_p = true;
layout test_layout (&dc, &richloc, DK_ERROR);
test_layout.print_line (1);
@@ -3287,19 +3292,19 @@ test_one_liner_multiple_carets_and_ranges ()
= make_location (linemap_position_for_column (line_table, 2),
linemap_position_for_column (line_table, 1),
linemap_position_for_column (line_table, 3));
- dc.caret_chars[0] = 'A';
+ dc.m_source_printing.caret_chars[0] = 'A';
location_t bar
= make_location (linemap_position_for_column (line_table, 8),
linemap_position_for_column (line_table, 7),
linemap_position_for_column (line_table, 9));
- dc.caret_chars[1] = 'B';
+ dc.m_source_printing.caret_chars[1] = 'B';
location_t field
= make_location (linemap_position_for_column (line_table, 13),
linemap_position_for_column (line_table, 11),
linemap_position_for_column (line_table, 15));
- dc.caret_chars[2] = 'C';
+ dc.m_source_printing.caret_chars[2] = 'C';
rich_location richloc (line_table, foo);
richloc.add_range (bar, SHOW_RANGE_WITH_CARET);
@@ -3382,8 +3387,8 @@ test_one_liner_fixit_remove ()
/* Normal, with ruler. */
{
test_diagnostic_context dc;
- dc.show_ruler_p = true;
- dc.caret_max_width = 104;
+ dc.m_source_printing.show_ruler_p = true;
+ dc.m_source_printing.max_width = 104;
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" 0 0 0 0 0 0 0 0 0 1 \n"
" 1 2 3 4 5 6 7 8 9 0 \n"
@@ -3397,8 +3402,8 @@ test_one_liner_fixit_remove ()
/* Test of adding a prefix, with ruler. */
{
test_diagnostic_context dc;
- dc.show_ruler_p = true;
- dc.caret_max_width = 50;
+ dc.m_source_printing.show_ruler_p = true;
+ dc.m_source_printing.max_width = 50;
pp_prefixing_rule (dc.printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
pp_set_prefix (dc.printer, xstrdup ("TEST PREFIX:"));
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
@@ -3413,9 +3418,9 @@ test_one_liner_fixit_remove ()
/* Test of adding a prefix, with ruler and line numbers. */
{
test_diagnostic_context dc;
- dc.show_ruler_p = true;
- dc.caret_max_width = 50;
- dc.show_line_numbers_p = true;
+ dc.m_source_printing.show_ruler_p = true;
+ dc.m_source_printing.max_width = 50;
+ dc.m_source_printing.show_line_numbers_p = true;
pp_prefixing_rule (dc.printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
pp_set_prefix (dc.printer, xstrdup ("TEST PREFIX:"));
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
@@ -3641,7 +3646,7 @@ test_one_liner_labels ()
/* Verify that we can disable label-printing. */
{
test_diagnostic_context dc;
- dc.show_labels_p = false;
+ dc.m_source_printing.show_labels_p = false;
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" foo = bar.field;\n"
" ^~~ ~~~ ~~~~~\n",
@@ -3895,19 +3900,19 @@ test_one_liner_multiple_carets_and_ranges_utf8 ()
= make_location (linemap_position_for_column (line_table, 7),
linemap_position_for_column (line_table, 1),
linemap_position_for_column (line_table, 8));
- dc.caret_chars[0] = 'A';
+ dc.m_source_printing.caret_chars[0] = 'A';
location_t bar
= make_location (linemap_position_for_column (line_table, 16),
linemap_position_for_column (line_table, 12),
linemap_position_for_column (line_table, 17));
- dc.caret_chars[1] = 'B';
+ dc.m_source_printing.caret_chars[1] = 'B';
location_t field
= make_location (linemap_position_for_column (line_table, 26),
linemap_position_for_column (line_table, 19),
linemap_position_for_column (line_table, 30));
- dc.caret_chars[2] = 'C';
+ dc.m_source_printing.caret_chars[2] = 'C';
rich_location richloc (line_table, foo);
richloc.add_range (bar, SHOW_RANGE_WITH_CARET);
richloc.add_range (field, SHOW_RANGE_WITH_CARET);
@@ -4348,7 +4353,7 @@ static void
test_one_liner_colorized_utf8 ()
{
test_diagnostic_context dc;
- dc.colorize_source_p = true;
+ dc.m_source_printing.colorize_source_p = true;
diagnostic_color_init (&dc, DIAGNOSTICS_COLOR_YES);
const location_t pi = linemap_position_for_column (line_table, 12);
rich_location richloc (line_table, pi);
@@ -4563,7 +4568,7 @@ test_diagnostic_show_locus_fixit_lines (const line_table_case &case_)
richloc.add_fixit_insert_before (y, ".");
richloc.add_fixit_replace (colon, "=");
test_diagnostic_context dc;
- dc.show_line_numbers_p = true;
+ dc.m_source_printing.show_line_numbers_p = true;
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" 3 | y\n"
" | .\n"
@@ -5304,7 +5309,7 @@ test_fixit_insert_containing_newline (const line_table_case &case_)
/* With line numbers. */
{
test_diagnostic_context dc;
- dc.show_line_numbers_p = true;
+ dc.m_source_printing.show_line_numbers_p = true;
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" 2 | x = a;\n"
" +++ |+ break;\n"
@@ -5383,7 +5388,7 @@ test_fixit_insert_containing_newline_2 (const line_table_case &case_)
consolidated, since it makes little sense to skip line 2. */
{
test_diagnostic_context dc;
- dc.show_line_numbers_p = true;
+ dc.m_source_printing.show_line_numbers_p = true;
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" +++ |+#include <stdio.h>\n"
" 1 | test (int ch)\n"
@@ -5679,8 +5684,8 @@ test_line_numbers_multiline_range ()
location_t loc = make_location (caret, start, finish);
test_diagnostic_context dc;
- dc.show_line_numbers_p = true;
- dc.min_margin_width = 0;
+ dc.m_source_printing.show_line_numbers_p = true;
+ dc.m_source_printing.min_margin_width = 0;
gcc_rich_location richloc (loc);
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" 9 | this is line 9\n"
diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index 28ab74f..b4bbd60 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -147,7 +147,7 @@ diagnostic_set_caret_max_width (diagnostic_context *context, int value)
if (value <= 0)
value = INT_MAX;
- context->caret_max_width = value;
+ context->m_source_printing.max_width = value;
}
/* Default implementation of final_cb. */
@@ -189,10 +189,10 @@ diagnostic_initialize (diagnostic_context *context, int n_opts)
context->classify_diagnostic = XNEWVEC (diagnostic_t, n_opts);
for (i = 0; i < n_opts; i++)
context->classify_diagnostic[i] = DK_UNSPECIFIED;
- context->show_caret = false;
+ context->m_source_printing.enabled = false;
diagnostic_set_caret_max_width (context, pp_line_cutoff (context->printer));
for (i = 0; i < rich_location::STATICALLY_ALLOCATED_RANGES; i++)
- context->caret_chars[i] = '^';
+ context->m_source_printing.caret_chars[i] = '^';
context->show_cwe = false;
context->show_rules = false;
context->path_format = DPF_NONE;
@@ -220,11 +220,11 @@ diagnostic_initialize (diagnostic_context *context, int n_opts)
context->x_data = NULL;
context->lock = 0;
context->inhibit_notes_p = false;
- context->colorize_source_p = false;
- context->show_labels_p = false;
- context->show_line_numbers_p = false;
- context->min_margin_width = 0;
- context->show_ruler_p = false;
+ context->m_source_printing.colorize_source_p = false;
+ context->m_source_printing.show_labels_p = false;
+ context->m_source_printing.show_line_numbers_p = false;
+ context->m_source_printing.min_margin_width = 0;
+ context->m_source_printing.show_ruler_p = false;
context->report_bug = false;
if (const char *var = getenv ("GCC_EXTRA_DIAGNOSTIC_OUTPUT"))
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index 4ec83a9..1f2d93c 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -219,16 +219,6 @@ struct diagnostic_context
int *push_list;
int n_push;
- /* True if we should print the source line with a caret indicating
- the location. */
- bool show_caret;
-
- /* Maximum width of the source line printed. */
- int caret_max_width;
-
- /* Character used for caret diagnostics. */
- char caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES];
-
/* True if we should print any CWE identifiers associated with
diagnostics. */
bool show_cwe;
@@ -336,29 +326,49 @@ struct diagnostic_context
bool inhibit_notes_p;
- /* When printing source code, should the characters at carets and ranges
- be colorized? (assuming colorization is on at all).
- This should be true for frontends that generate range information
- (so that the ranges of code are colorized),
- and false for frontends that merely specify points within the
- source code (to avoid e.g. colorizing just the first character in
- a token, which would look strange). */
- bool colorize_source_p;
+ /* Fields relating to printing the user's source code (potentially with
+ a margin, underlining, labels, etc). */
+ struct {
+
+ /* True if we should print the source line with a caret indicating
+ the location.
+ Corresponds to -fdiagnostics-show-caret. */
+ bool enabled;
+
+ /* Maximum width of the source line printed. */
+ int max_width;
+
+ /* Character used at the caret when printing source locations. */
+ char caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES];
+
+ /* When printing source code, should the characters at carets and ranges
+ be colorized? (assuming colorization is on at all).
+ This should be true for frontends that generate range information
+ (so that the ranges of code are colorized),
+ and false for frontends that merely specify points within the
+ source code (to avoid e.g. colorizing just the first character in
+ a token, which would look strange). */
+ bool colorize_source_p;
+
+ /* When printing source code, should labelled ranges be printed?
+ Corresponds to -fdiagnostics-show-labels. */
+ bool show_labels_p;
- /* When printing source code, should labelled ranges be printed? */
- bool show_labels_p;
+ /* When printing source code, should there be a left-hand margin
+ showing line numbers?
+ Corresponds to -fdiagnostics-show-line-numbers. */
+ bool show_line_numbers_p;
- /* When printing source code, should there be a left-hand margin
- showing line numbers? */
- bool show_line_numbers_p;
+ /* If printing source code, what should the minimum width of the margin
+ be? Line numbers will be right-aligned, and padded to this width.
+ Corresponds to -fdiagnostics-minimum-margin-width=VALUE. */
+ int min_margin_width;
- /* If printing source code, what should the minimum width of the margin
- be? Line numbers will be right-aligned, and padded to this width. */
- int min_margin_width;
+ /* Usable by plugins; if true, print a debugging ruler above the
+ source output. */
+ bool show_ruler_p;
- /* Usable by plugins; if true, print a debugging ruler above the
- source output. */
- bool show_ruler_p;
+ } m_source_printing;
/* True if -freport-bug option is used. */
bool report_bug;
@@ -605,8 +615,9 @@ inline bool
diagnostic_same_line (const diagnostic_context *context,
expanded_location s1, expanded_location s2)
{
- return s2.column && s1.line == s2.line
- && context->caret_max_width - CARET_LINE_MARGIN > abs (s1.column - s2.column);
+ return (s2.column && s1.line == s2.line
+ && (context->m_source_printing.max_width - CARET_LINE_MARGIN
+ > abs (s1.column - s2.column)));
}
extern const char *diagnostic_get_color_for_kind (diagnostic_t kind);
diff --git a/gcc/fortran/error.cc b/gcc/fortran/error.cc
index 6cae672..378f739 100644
--- a/gcc/fortran/error.cc
+++ b/gcc/fortran/error.cc
@@ -1222,7 +1222,7 @@ gfc_diagnostic_starter (diagnostic_context *context,
? gfc_diagnostic_build_locus_prefix (context, s1)
: gfc_diagnostic_build_locus_prefix (context, s1, s2);
- if (!context->show_caret
+ if (!context->m_source_printing.enabled
|| diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION
|| diagnostic_location (diagnostic, 0) == context->last_location)
{
@@ -1640,8 +1640,8 @@ gfc_diagnostics_init (void)
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';
- global_dc->caret_chars[1] = '2';
+ global_dc->m_source_printing.caret_chars[0] = '1';
+ global_dc->m_source_printing.caret_chars[1] = '2';
pp_warning_buffer = new (XNEW (output_buffer)) output_buffer ();
pp_warning_buffer->flush_p = false;
/* pp_error_buffer is statically allocated. This simplifies memory
@@ -1658,6 +1658,6 @@ gfc_diagnostics_finish (void)
defaults. */
diagnostic_starter (global_dc) = gfc_diagnostic_starter;
diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer;
- global_dc->caret_chars[0] = '^';
- global_dc->caret_chars[1] = '^';
+ global_dc->m_source_printing.caret_chars[0] = '^';
+ global_dc->m_source_printing.caret_chars[1] = '^';
}
diff --git a/gcc/opts.cc b/gcc/opts.cc
index ac81d4e..573dcf8 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -2864,15 +2864,15 @@ common_handle_option (struct gcc_options *opts,
break;
case OPT_fdiagnostics_show_caret:
- dc->show_caret = value;
+ dc->m_source_printing.enabled = value;
break;
case OPT_fdiagnostics_show_labels:
- dc->show_labels_p = value;
+ dc->m_source_printing.show_labels_p = value;
break;
case OPT_fdiagnostics_show_line_numbers:
- dc->show_line_numbers_p = value;
+ dc->m_source_printing.show_line_numbers_p = value;
break;
case OPT_fdiagnostics_color_:
@@ -2936,7 +2936,7 @@ common_handle_option (struct gcc_options *opts,
break;
case OPT_fdiagnostics_minimum_margin_width_:
- dc->min_margin_width = value;
+ dc->m_source_printing.min_margin_width = value;
break;
case OPT_fdump_:
diff --git a/gcc/selftest-diagnostic.cc b/gcc/selftest-diagnostic.cc
index 6d1bd1b..5469e55 100644
--- a/gcc/selftest-diagnostic.cc
+++ b/gcc/selftest-diagnostic.cc
@@ -36,12 +36,12 @@ namespace selftest {
test_diagnostic_context::test_diagnostic_context ()
{
diagnostic_initialize (this, 0);
- show_caret = true;
- show_labels_p = true;
+ m_source_printing.enabled = true;
+ m_source_printing.show_labels_p = true;
show_column = true;
start_span = start_span_cb;
- min_margin_width = 6;
- caret_max_width = 80;
+ m_source_printing.min_margin_width = 6;
+ m_source_printing.max_width = 80;
}
test_diagnostic_context::~test_diagnostic_context ()
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
index d81fa57..f5c6fc5 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
@@ -115,7 +115,7 @@ plugin_init (struct plugin_name_args *plugin_info,
if (!plugin_default_version_check (version, &gcc_version))
return 1;
- global_dc->caret_max_width = 80;
+ global_dc->m_source_printing.max_width = 80;
register_callback (plugin_name,
PLUGIN_PRE_GENERICIZE,
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c
index 3627f7a..7edce1f 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c
@@ -169,7 +169,7 @@ plugin_init (struct plugin_name_args *plugin_info,
if (!plugin_default_version_check (version, &gcc_version))
return 1;
- global_dc->caret_max_width = 80;
+ global_dc->m_source_printing.max_width = 80;
pass_info.pass = new pass_test_inlining (g);
pass_info.reference_pass_name = "*warn_function_noreturn";
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c
index 62558be..bf66500 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c
@@ -534,7 +534,7 @@ plugin_init (struct plugin_name_args *plugin_info,
if (!plugin_default_version_check (version, &gcc_version))
return 1;
- global_dc->caret_max_width = 80;
+ global_dc->m_source_printing.max_width = 80;
pass_info.pass = make_pass_test_show_path (g);
pass_info.reference_pass_name = "whole-program";
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
index baa6b62..2b8cbc9 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
@@ -175,7 +175,7 @@ test_show_locus (function *fun)
/* Hardcode the "terminal width", to verify the behavior of
very wide lines. */
- global_dc->caret_max_width = 71;
+ global_dc->m_source_printing.max_width = 71;
if (0 == strcmp (fnname, "test_simple"))
{
@@ -246,7 +246,7 @@ test_show_locus (function *fun)
if (0 == strcmp (fnname, "test_very_wide_line"))
{
const int line = fnstart_line + 2;
- global_dc->show_ruler_p = true;
+ global_dc->m_source_printing.show_ruler_p = true;
text_range_label label0 ("label 0");
text_range_label label1 ("label 1");
rich_location richloc (line_table,
@@ -258,7 +258,7 @@ test_show_locus (function *fun)
&label1);
richloc.add_fixit_replace ("bar * foo");
warning_at (&richloc, 0, "test");
- global_dc->show_ruler_p = false;
+ global_dc->m_source_printing.show_ruler_p = false;
}
/* Likewise, but with a secondary location that's immediately before
@@ -266,7 +266,7 @@ test_show_locus (function *fun)
if (0 == strcmp (fnname, "test_very_wide_line_2"))
{
const int line = fnstart_line + 2;
- global_dc->show_ruler_p = true;
+ global_dc->m_source_printing.show_ruler_p = true;
text_range_label label0 ("label 0");
text_range_label label1 ("label 1");
rich_location richloc (line_table,
@@ -278,7 +278,7 @@ test_show_locus (function *fun)
richloc.add_range (get_loc (line, 34), SHOW_RANGE_WITHOUT_CARET,
&label1);
warning_at (&richloc, 0, "test");
- global_dc->show_ruler_p = false;
+ global_dc->m_source_printing.show_ruler_p = false;
}
/* Example of multiple carets. */
@@ -289,11 +289,11 @@ test_show_locus (function *fun)
location_t caret_b = get_loc (line, 11);
rich_location richloc (line_table, caret_a);
add_range (&richloc, caret_b, caret_b, SHOW_RANGE_WITH_CARET);
- global_dc->caret_chars[0] = 'A';
- global_dc->caret_chars[1] = 'B';
+ global_dc->m_source_printing.caret_chars[0] = 'A';
+ global_dc->m_source_printing.caret_chars[1] = 'B';
warning_at (&richloc, 0, "test");
- global_dc->caret_chars[0] = '^';
- global_dc->caret_chars[1] = '^';
+ global_dc->m_source_printing.caret_chars[0] = '^';
+ global_dc->m_source_printing.caret_chars[1] = '^';
}
/* Tests of rendering fixit hints. */
@@ -407,11 +407,11 @@ test_show_locus (function *fun)
location_t caret_b = get_loc (line - 1, 19);
rich_location richloc (line_table, caret_a);
richloc.add_range (caret_b, SHOW_RANGE_WITH_CARET);
- global_dc->caret_chars[0] = '1';
- global_dc->caret_chars[1] = '2';
+ global_dc->m_source_printing.caret_chars[0] = '1';
+ global_dc->m_source_printing.caret_chars[1] = '2';
warning_at (&richloc, 0, "test");
- global_dc->caret_chars[0] = '^';
- global_dc->caret_chars[1] = '^';
+ global_dc->m_source_printing.caret_chars[0] = '^';
+ global_dc->m_source_printing.caret_chars[1] = '^';
}
/* Example of using the "%q+D" format code, which as well as printing
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
index 0269f72..1b5fad2 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
@@ -208,7 +208,7 @@ plugin_init (struct plugin_name_args *plugin_info,
if (!plugin_default_version_check (version, &gcc_version))
return 1;
- global_dc->caret_max_width = 80;
+ global_dc->m_source_printing.max_width = 80;
pass_info.pass = new pass_test_string_literals (g);
pass_info.reference_pass_name = "ssa";
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
index f546863..fbdb2f8 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
@@ -89,7 +89,7 @@ plugin_init (struct plugin_name_args *plugin_info,
if (!plugin_default_version_check (version, &gcc_version))
return 1;
- global_dc->caret_max_width = 130;
+ global_dc->m_source_printing.max_width = 130;
register_callback (plugin_name,
PLUGIN_PRE_GENERICIZE,
diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index db62e3e..626cc43 100644
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -1023,11 +1023,11 @@ general_init (const char *argv0, bool init_signals)
override it later. */
tree_diagnostics_defaults (global_dc);
- global_dc->show_caret
+ global_dc->m_source_printing.enabled
= global_options_init.x_flag_diagnostics_show_caret;
- global_dc->show_labels_p
+ global_dc->m_source_printing.show_labels_p
= global_options_init.x_flag_diagnostics_show_labels;
- global_dc->show_line_numbers_p
+ global_dc->m_source_printing.show_line_numbers_p
= global_options_init.x_flag_diagnostics_show_line_numbers;
global_dc->show_cwe
= global_options_init.x_flag_diagnostics_show_cwe;
@@ -1039,7 +1039,7 @@ general_init (const char *argv0, bool init_signals)
= global_options_init.x_flag_diagnostics_show_path_depths;
global_dc->show_option_requested
= global_options_init.x_flag_diagnostics_show_option;
- global_dc->min_margin_width
+ global_dc->m_source_printing.min_margin_width
= global_options_init.x_diagnostics_minimum_margin_width;
global_dc->show_column
= global_options_init.x_flag_show_column;
diff --git a/gcc/tree-diagnostic-path.cc b/gcc/tree-diagnostic-path.cc
index 84148da..b1b483a 100644
--- a/gcc/tree-diagnostic-path.cc
+++ b/gcc/tree-diagnostic-path.cc
@@ -200,7 +200,7 @@ struct event_range
/* Emit a span indicating the filename (and line/column) if the
line has changed relative to the last call to
diagnostic_show_locus. */
- if (dc->show_caret)
+ if (dc->m_source_printing.enabled)
{
expanded_location exploc
= linemap_client_expand_location_to_spelling_point