bool added_matching_location = false;
if (matching_location != UNKNOWN_LOCATION)
added_matching_location
- = richloc.add_location_if_nearby (matching_location);
+ = richloc.add_location_if_nearby (*global_dc, matching_location);
if (c_parser_error_richloc (parser, msgid, &richloc))
/* If we weren't able to consolidate matching_location, then
secondary range within the main diagnostic. */
if (matching_location != UNKNOWN_LOCATION)
added_matching_location
- = richloc.add_location_if_nearby (matching_location);
+ = richloc.add_location_if_nearby (*global_dc,
+ matching_location);
}
/* If we were parsing a string-literal and there is an unknown name
break;
gcc_rich_location richloc (token->location);
location_t oloc = decl_specs->locations[ds_storage_class];
- richloc.add_location_if_nearby (oloc);
+ richloc.add_location_if_nearby (*global_dc, oloc);
error_at (&richloc,
"%<typedef%> specifier conflicts with %qs",
cp_storage_class_name[decl_specs->storage_class]);
if (decl_specs->conflicting_specifiers_p)
return;
gcc_rich_location richloc (token->location);
- richloc.add_location_if_nearby (decl_specs->locations[ds_storage_class]);
+ richloc.add_location_if_nearby (*global_dc,
+ decl_specs->locations[ds_storage_class]);
if (decl_specs->storage_class == storage_class)
error_at (&richloc, "duplicate %qD specifier", ridpointers[keyword]);
else
&& !decl_specs->conflicting_specifiers_p)
{
gcc_rich_location richloc (token->location);
- richloc.add_location_if_nearby (decl_specs->locations[ds_typedef]);
+ richloc.add_location_if_nearby (*global_dc,
+ decl_specs->locations[ds_typedef]);
error_at (&richloc,
"%qD specifier conflicts with %<typedef%>",
ridpointers[keyword]);
class path_label : public range_label
{
public:
- path_label (const diagnostic_path *path, unsigned start_idx)
- : m_path (path), m_start_idx (start_idx), m_effects (*this)
+ path_label (const diagnostic_context &ctxt,
+ const diagnostic_path *path,
+ unsigned start_idx)
+ : m_ctxt (ctxt), m_path (path), m_start_idx (start_idx), m_effects (*this)
{}
label_text get_text (unsigned range_idx) const final override
/* Get the description of the event, perhaps with colorization:
normally, we don't colorize within a range_label, but this
is special-cased for diagnostic paths. */
- const bool colorize = pp_show_color (global_dc->printer);
+ const bool colorize = pp_show_color (m_ctxt.printer);
label_text event_text (event.get_desc (colorize));
gcc_assert (event_text.get ());
pp_space (&pp);
if (meaning.m_verb == diagnostic_event::VERB_danger)
- if (text_art::theme *theme = global_dc->get_diagram_theme ())
+ if (text_art::theme *theme = m_ctxt.get_diagram_theme ())
if (theme->emojis_p ())
{
pp_unicode_character (&pp, 0x26A0); /* U+26A0 WARNING SIGN. */
return &m_path->get_event (event_idx);
}
+ const diagnostic_context &m_ctxt;
const diagnostic_path *m_path;
unsigned m_start_idx;
path_label_effects m_effects;
int m_max_label_source_column;
};
- event_range (const diagnostic_path *path, unsigned start_idx,
+ event_range (const diagnostic_context &ctxt,
+ const diagnostic_path *path, unsigned start_idx,
const diagnostic_event &initial_event,
per_thread_summary &t,
bool show_event_links)
m_logical_loc (initial_event.get_logical_location ()),
m_stack_depth (initial_event.get_stack_depth ()),
m_start_idx (start_idx), m_end_idx (start_idx),
- m_path_label (path, start_idx),
+ m_path_label (ctxt, path, start_idx),
m_richloc (initial_event.get_location (), &m_path_label),
m_thread_id (initial_event.get_thread_id ()),
m_per_thread_summary (t),
return result;
}
- bool maybe_add_event (const diagnostic_event &new_ev,
+ bool maybe_add_event (const diagnostic_context &ctxt,
+ const diagnostic_event &new_ev,
unsigned new_ev_idx,
bool check_rich_locations)
{
/* Potentially verify that the locations are sufficiently close. */
if (check_rich_locations)
- if (!m_richloc.add_location_if_nearby (new_ev.get_location (),
+ if (!m_richloc.add_location_if_nearby (ctxt, new_ev.get_location (),
false, &m_path_label))
return false;
struct path_summary
{
- path_summary (const diagnostic_path &path,
+ path_summary (const diagnostic_context &ctxt,
+ const diagnostic_path &path,
bool check_rich_locations,
bool show_event_links = true);
/* path_summary's ctor. */
-path_summary::path_summary (const diagnostic_path &path,
+path_summary::path_summary (const diagnostic_context &ctxt,
+ const diagnostic_path &path,
bool check_rich_locations,
bool show_event_links)
{
pts.update_depth_limits (event.get_stack_depth ());
if (cur_event_range)
- if (cur_event_range->maybe_add_event (event, idx, check_rich_locations))
+ if (cur_event_range->maybe_add_event (ctxt, event,
+ idx, check_rich_locations))
continue;
- cur_event_range = new event_range (&path, idx, event, pts,
+ cur_event_range = new event_range (ctxt, &path, idx, event, pts,
show_event_links);
m_ranges.safe_push (cur_event_range);
pts.m_event_ranges.safe_push (cur_event_range);
case DPF_INLINE_EVENTS:
{
/* Consolidate related events. */
- path_summary summary (*path, true,
+ path_summary summary (*this, *path, true,
m_source_printing.show_event_links_p);
char *saved_prefix = pp_take_prefix (this->printer);
pp_set_prefix (this->printer, NULL);
test_diagnostic_path path (event_pp);
ASSERT_FALSE (path.interprocedural_p ());
- path_summary summary (path, false);
+ test_diagnostic_context dc;
+ path_summary summary (dc, path, false);
ASSERT_EQ (summary.get_num_ranges (), 0);
- test_diagnostic_context dc;
print_path_summary_as_text (&summary, &dc, true);
ASSERT_STREQ ("",
pp_formatted_text (dc.printer));
ASSERT_FALSE (path.interprocedural_p ());
- path_summary summary (path, false);
+ test_diagnostic_context dc;
+ path_summary summary (dc, path, false);
ASSERT_EQ (summary.get_num_ranges (), 1);
- test_diagnostic_context dc;
print_path_summary_as_text (&summary, &dc, true);
ASSERT_STREQ (" `foo': events 1-2 (depth 0)\n"
" (1): first `free'\n"
ASSERT_TRUE (path.interprocedural_p ());
- path_summary summary (path, false);
- ASSERT_EQ (summary.get_num_ranges (), 9);
-
{
test_diagnostic_context dc;
+ path_summary summary (dc, path, false);
+ ASSERT_EQ (summary.get_num_ranges (), 9);
+
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_ASCII);
print_path_summary_as_text (&summary, &dc, true);
ASSERT_STREQ
{
test_diagnostic_context dc;
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_UNICODE);
+ path_summary summary (dc, path, false);
print_path_summary_as_text (&summary, &dc, true);
ASSERT_STREQ
(" `test': events 1-2 (depth 0)\n"
ASSERT_TRUE (path.interprocedural_p ());
- path_summary summary (path, false);
- ASSERT_EQ (summary.get_num_ranges (), 5);
-
{
test_diagnostic_context dc;
+ path_summary summary (dc, path, false);
+ ASSERT_EQ (summary.get_num_ranges (), 5);
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_ASCII);
print_path_summary_as_text (&summary, &dc, true);
ASSERT_STREQ
{
test_diagnostic_context dc;
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_UNICODE);
+ path_summary summary (dc, path, false);
print_path_summary_as_text (&summary, &dc, true);
ASSERT_STREQ
(" `foo': events 1-2 (depth 0)\n"
ASSERT_TRUE (path.interprocedural_p ());
- path_summary summary (path, false);
- ASSERT_EQ (summary.get_num_ranges (), 4);
-
{
test_diagnostic_context dc;
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_ASCII);
+
+ path_summary summary (dc, path, false);
+ ASSERT_EQ (summary.get_num_ranges (), 4);
+
print_path_summary_as_text (&summary, &dc, true);
ASSERT_STREQ
(" `factorial': events 1-2 (depth 0)\n"
{
test_diagnostic_context dc;
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_UNICODE);
+
+ path_summary summary (dc, path, false);
print_path_summary_as_text (&summary, &dc, true);
ASSERT_STREQ
(" `factorial': events 1-2 (depth 0)\n"
if (!path_events_have_column_data_p (path))
return;
- path_summary summary (path, true /*false*/);
{
test_diagnostic_context dc;
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_ASCII);
dc.m_source_printing.show_event_links_p = true;
+ path_summary summary (dc, path, true);
print_path_summary_as_text (&summary, &dc, false);
ASSERT_STREQ
(" events 1-3\n"
test_diagnostic_context dc;
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_ASCII);
dc.m_source_printing.show_event_links_p = false;
+ path_summary summary (dc, path, true);
print_path_summary_as_text (&summary, &dc, false);
ASSERT_STREQ
(" events 1-3\n"
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_ASCII);
dc.m_source_printing.show_line_numbers_p = true;
dc.m_source_printing.show_event_links_p = true;
+ path_summary summary (dc, path, true);
print_path_summary_as_text (&summary, &dc, false);
ASSERT_STREQ
(" events 1-3\n"
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_ASCII);
dc.m_source_printing.show_line_numbers_p = true;
dc.m_source_printing.show_event_links_p = false;
+ path_summary summary (dc, path, true);
print_path_summary_as_text (&summary, &dc, false);
ASSERT_STREQ
(" events 1-3\n"
test_diagnostic_context dc;
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_UNICODE);
dc.m_source_printing.show_event_links_p = true;
+ path_summary summary (dc, path, true);
print_path_summary_as_text (&summary, &dc, false);
ASSERT_STREQ
(" events 1-3\n"
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_UNICODE);
dc.m_source_printing.show_event_links_p = true;
dc.m_source_printing.show_line_numbers_p = true;
+ path_summary summary (dc, path, true);
print_path_summary_as_text (&summary, &dc, false);
ASSERT_STREQ
(" events 1-3\n"
if (!path_events_have_column_data_p (path))
return;
- path_summary summary (path, true);
-
{
test_diagnostic_context dc;
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_ASCII);
dc.m_source_printing.show_event_links_p = true;
dc.m_source_printing.show_line_numbers_p = true;
+ path_summary summary (dc, path, true);
print_path_summary_as_text (&summary, &dc, false);
ASSERT_STREQ
(" events 1-3\n"
if (!path_events_have_column_data_p (path))
return;
- path_summary summary (path, true);
-
{
test_diagnostic_context dc;
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_ASCII);
dc.m_source_printing.show_event_links_p = true;
dc.m_source_printing.show_line_numbers_p = true;
+ path_summary summary (dc, path, true);
print_path_summary_as_text (&summary, &dc, false);
ASSERT_STREQ
(" events 1-2\n"
if (!path_events_have_column_data_p (path))
return;
- path_summary summary (path, true);
-
test_diagnostic_context dc;
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_ASCII);
dc.m_source_printing.show_event_links_p = true;
dc.m_source_printing.show_line_numbers_p = true;
+ path_summary summary (dc, path, true);
print_path_summary_as_text (&summary, &dc, false);
ASSERT_STREQ_AT (loc, expected_str,
pp_formatted_text (dc.printer));
if (!path_events_have_column_data_p (path))
return;
- path_summary summary (path, true);
-
{
test_diagnostic_context dc;
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_ASCII);
dc.m_source_printing.show_event_links_p = true;
dc.m_source_printing.show_line_numbers_p = true;
+ path_summary summary (dc, path, true);
print_path_summary_as_text (&summary, &dc, false);
ASSERT_STREQ
(" events 1-5\n"
if (!path_events_have_column_data_p (path))
return;
- path_summary summary (path, true);
-
{
test_diagnostic_context dc;
dc.set_text_art_charset (DIAGNOSTICS_TEXT_ART_CHARSET_ASCII);
dc.m_source_printing.show_event_links_p = true;
dc.m_source_printing.show_line_numbers_p = true;
+ path_summary summary (dc, path, true);
print_path_summary_as_text (&summary, &dc, false);
ASSERT_STREQ
(" events 1-3\n"
static void
control_flow_tests (const line_table_case &case_)
{
- std::unique_ptr<pretty_printer> event_pp
- = std::unique_ptr<pretty_printer> (global_dc->printer->clone ());
- pp_show_color (event_pp.get ()) = false;
-
- test_control_flow_1 (case_, event_pp.get ());
- test_control_flow_2 (case_, event_pp.get ());
- test_control_flow_3 (case_, event_pp.get ());
- test_control_flow_4 (case_, event_pp.get ());
- test_control_flow_5 (case_, event_pp.get ());
- test_control_flow_6 (case_, event_pp.get ());
+ pretty_printer pp;
+ pp_show_color (&pp) = false;
+
+ test_control_flow_1 (case_, &pp);
+ test_control_flow_2 (case_, &pp);
+ test_control_flow_3 (case_, &pp);
+ test_control_flow_4 (case_, &pp);
+ test_control_flow_5 (case_, &pp);
+ test_control_flow_6 (case_, &pp);
}
/* Run all of the selftests within this file. */
void
diagnostic_path_cc_tests ()
{
- /* In a few places we use the global dc's printer to determine
- colorization so ensure this off during the tests. */
- bool saved_show_color = pp_show_color (global_dc->printer);
- pp_show_color (global_dc->printer) = false;
+ pretty_printer pp;
+ pp_show_color (&pp) = false;
auto_fix_quotes fix_quotes;
- std::unique_ptr<pretty_printer> event_pp
- = std::unique_ptr<pretty_printer> (global_dc->printer->clone ());
- test_empty_path (event_pp.get ());
- test_intraprocedural_path (event_pp.get ());
- test_interprocedural_path_1 (event_pp.get ());
- test_interprocedural_path_2 (event_pp.get ());
- test_recursion (event_pp.get ());
+ test_empty_path (&pp);
+ test_intraprocedural_path (&pp);
+ test_interprocedural_path_1 (&pp);
+ test_interprocedural_path_2 (&pp);
+ test_recursion (&pp);
for_each_line_table_case (control_flow_tests);
-
- pp_show_color (global_dc->printer) = saved_show_color;
}
} // namespace selftest
/* If LOC is within the spans of lines that will already be printed for
this gcc_rich_location, then add it as a secondary location and return true.
- Otherwise return false. */
+ Otherwise return false.
+
+ Use CTXT for determining how spans of lines would be printed. */
bool
-gcc_rich_location::add_location_if_nearby (location_t loc,
+gcc_rich_location::add_location_if_nearby (const diagnostic_context &ctxt,
+ location_t loc,
bool restrict_to_current_line_spans,
const range_label *label)
{
/* Use the layout location-handling logic to sanitize LOC,
filtering it to the current line spans within a temporary
layout instance. */
- layout layout (*global_dc, *this, DK_ERROR, nullptr);
+ layout layout (ctxt, *this, DK_ERROR, nullptr);
location_range loc_range;
loc_range.m_loc = loc;
loc_range.m_range_display_kind = SHOW_RANGE_WITHOUT_CARET;
" double x;\n" /* line 4. */
" double y;\n" /* line 5. */
";\n"); /* line 6. */
- temp_source_file tmp (SELFTEST_LOCATION, ".c", content,
-
- /* gcc_rich_location::add_location_if_nearby implicitly
- uses global_dc's file_cache, so we need to evict
- tmp when we're done. */
- &global_dc->get_file_cache ());
+ temp_source_file tmp (SELFTEST_LOCATION, ".c", content, nullptr);
line_table_test ltt (case_);
const line_map_ordinary *ord_map
/* Test of add_location_if_nearby on the same line as the
primary location. */
{
+ test_diagnostic_context dc;
const location_t missing_close_brace_1_39
= linemap_position_for_line_and_column (line_table, ord_map, 1, 39);
const location_t matching_open_brace_1_18
= linemap_position_for_line_and_column (line_table, ord_map, 1, 18);
gcc_rich_location richloc (missing_close_brace_1_39);
- bool added = richloc.add_location_if_nearby (matching_open_brace_1_18);
+ bool added = richloc.add_location_if_nearby (dc,
+ matching_open_brace_1_18);
ASSERT_TRUE (added);
ASSERT_EQ (2, richloc.get_num_locations ());
- test_diagnostic_context dc;
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" struct same_line { double x; double y; ;\n"
" ~ ^\n",
/* Test of add_location_if_nearby on a different line to the
primary location. */
{
+ test_diagnostic_context dc;
const location_t missing_close_brace_6_1
= linemap_position_for_line_and_column (line_table, ord_map, 6, 1);
const location_t matching_open_brace_3_1
= linemap_position_for_line_and_column (line_table, ord_map, 3, 1);
gcc_rich_location richloc (missing_close_brace_6_1);
- bool added = richloc.add_location_if_nearby (matching_open_brace_3_1);
+ bool added = richloc.add_location_if_nearby (dc,
+ matching_open_brace_3_1);
ASSERT_FALSE (added);
ASSERT_EQ (1, richloc.get_num_locations ());
}
# pragma GCC diagnostic ignored "-Wformat-diag"
#endif
-#define pedantic_warning_kind(DC) \
- ((DC)->m_pedantic_errors ? DK_ERROR : DK_WARNING)
-#define permissive_error_kind(DC) ((DC)->m_permissive ? DK_WARNING : DK_ERROR)
-#define permissive_error_option(DC) ((DC)->m_opt_permissive)
-
-/* Prototypes. */
-static bool diagnostic_impl (rich_location *, const diagnostic_metadata *,
- int, const char *,
- va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(4,0);
-static bool diagnostic_n_impl (rich_location *, const diagnostic_metadata *,
- int, unsigned HOST_WIDE_INT,
- const char *, const char *, va_list *,
- diagnostic_t) ATTRIBUTE_GCC_DIAG(6,0);
-
static void real_abort (void) ATTRIBUTE_NORETURN;
/* Name of program invoked, sans directories. */
/* Diagnostics with no option or -fpermissive are always enabled. */
if (!diagnostic->option_index
- || diagnostic->option_index == permissive_error_option (this))
+ || diagnostic->option_index == m_opt_permissive)
return true;
/* This tests if the user provided the appropriate -Wfoo or
if (diagnostic->kind == DK_PEDWARN)
{
- diagnostic->kind = pedantic_warning_kind (this);
+ diagnostic->kind = m_pedantic_errors ? DK_ERROR : DK_WARNING;
+
/* We do this to avoid giving the message for -pedantic-errors. */
orig_diag_kind = diagnostic->kind;
}
/* Implement emit_diagnostic, inform, warning, warning_at, pedwarn,
permerror, error, error_at, error_at, sorry, fatal_error, internal_error,
and internal_error_no_backtrace, as documented and defined below. */
-static bool
-diagnostic_impl (rich_location *richloc, const diagnostic_metadata *metadata,
- int opt, const char *gmsgid,
- va_list *ap, diagnostic_t kind)
+bool
+diagnostic_context::diagnostic_impl (rich_location *richloc,
+ const diagnostic_metadata *metadata,
+ int opt, const char *gmsgid,
+ va_list *ap, diagnostic_t kind)
{
diagnostic_info diagnostic;
if (kind == DK_PERMERROR)
{
diagnostic_set_info (&diagnostic, gmsgid, ap, richloc,
- permissive_error_kind (global_dc));
- diagnostic.option_index = (opt != -1 ? opt
- : permissive_error_option (global_dc));
+ m_permissive ? DK_WARNING : DK_ERROR);
+ diagnostic.option_index = (opt != -1 ? opt : m_opt_permissive);
}
else
{
diagnostic.option_index = opt;
}
diagnostic.metadata = metadata;
- return global_dc->report_diagnostic (&diagnostic);
+ return report_diagnostic (&diagnostic);
}
/* Implement inform_n, warning_n, and error_n, as documented and
defined below. */
-static bool
-diagnostic_n_impl (rich_location *richloc, const diagnostic_metadata *metadata,
- int opt, unsigned HOST_WIDE_INT n,
- const char *singular_gmsgid,
- const char *plural_gmsgid,
- va_list *ap, diagnostic_t kind)
+bool
+diagnostic_context::diagnostic_n_impl (rich_location *richloc,
+ const diagnostic_metadata *metadata,
+ int opt, unsigned HOST_WIDE_INT n,
+ const char *singular_gmsgid,
+ const char *plural_gmsgid,
+ va_list *ap, diagnostic_t kind)
{
diagnostic_info diagnostic;
unsigned long gtn;
if (kind == DK_WARNING)
diagnostic.option_index = opt;
diagnostic.metadata = metadata;
- return global_dc->report_diagnostic (&diagnostic);
+ return report_diagnostic (&diagnostic);
}
/* Wrapper around diagnostic_impl taking a variable argument list. */
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, location);
- bool ret = diagnostic_impl (&richloc, NULL, opt, gmsgid, &ap, kind);
+ bool ret = global_dc->diagnostic_impl (&richloc, nullptr, opt, gmsgid, &ap,
+ kind);
va_end (ap);
return ret;
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- bool ret = diagnostic_impl (richloc, NULL, opt, gmsgid, &ap, kind);
+ bool ret = global_dc->diagnostic_impl (richloc, nullptr, opt, gmsgid, &ap,
+ kind);
va_end (ap);
return ret;
}
const char *gmsgid, va_list *ap)
{
rich_location richloc (line_table, location);
- return diagnostic_impl (&richloc, NULL, opt, gmsgid, ap, kind);
+ return global_dc->diagnostic_impl (&richloc, nullptr, opt, gmsgid, ap, kind);
}
/* As above, but with rich_location and metadata. */
int opt,
const char *gmsgid, va_list *ap)
{
- return diagnostic_impl (richloc, metadata, opt, gmsgid, ap, kind);
+ return global_dc->diagnostic_impl (richloc, metadata, opt, gmsgid, ap, kind);
}
/* An informative note at LOCATION. Use this for additional details on an error
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, location);
- diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_NOTE);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_NOTE);
va_end (ap);
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- diagnostic_impl (richloc, NULL, -1, gmsgid, &ap, DK_NOTE);
+ global_dc->diagnostic_impl (richloc, nullptr, -1, gmsgid, &ap, DK_NOTE);
va_end (ap);
}
va_start (ap, plural_gmsgid);
auto_diagnostic_group d;
rich_location richloc (line_table, location);
- diagnostic_n_impl (&richloc, NULL, -1, n, singular_gmsgid, plural_gmsgid,
- &ap, DK_NOTE);
+ global_dc->diagnostic_n_impl (&richloc, nullptr, -1, n,
+ singular_gmsgid, plural_gmsgid,
+ &ap, DK_NOTE);
va_end (ap);
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, input_location);
- bool ret = diagnostic_impl (&richloc, NULL, opt, gmsgid, &ap, DK_WARNING);
+ bool ret = global_dc->diagnostic_impl (&richloc, nullptr, opt, gmsgid, &ap,
+ DK_WARNING);
va_end (ap);
return ret;
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, location);
- bool ret = diagnostic_impl (&richloc, NULL, opt, gmsgid, &ap, DK_WARNING);
+ bool ret = global_dc->diagnostic_impl (&richloc, nullptr, opt, gmsgid, &ap,
+ DK_WARNING);
va_end (ap);
return ret;
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- bool ret = diagnostic_impl (richloc, NULL, opt, gmsgid, &ap, DK_WARNING);
+ bool ret = global_dc->diagnostic_impl (richloc, nullptr, opt, gmsgid, &ap,
+ DK_WARNING);
va_end (ap);
return ret;
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- bool ret
- = diagnostic_impl (richloc, &metadata, opt, gmsgid, &ap,
- DK_WARNING);
+ bool ret = global_dc->diagnostic_impl (richloc, &metadata, opt, gmsgid, &ap,
+ DK_WARNING);
va_end (ap);
return ret;
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, plural_gmsgid);
- bool ret = diagnostic_n_impl (richloc, NULL, opt, n,
- singular_gmsgid, plural_gmsgid,
- &ap, DK_WARNING);
+ bool ret = global_dc->diagnostic_n_impl (richloc, nullptr, opt, n,
+ singular_gmsgid, plural_gmsgid,
+ &ap, DK_WARNING);
va_end (ap);
return ret;
}
va_list ap;
va_start (ap, plural_gmsgid);
rich_location richloc (line_table, location);
- bool ret = diagnostic_n_impl (&richloc, NULL, opt, n,
- singular_gmsgid, plural_gmsgid,
- &ap, DK_WARNING);
+ bool ret = global_dc->diagnostic_n_impl (&richloc, nullptr, opt, n,
+ singular_gmsgid, plural_gmsgid,
+ &ap, DK_WARNING);
va_end (ap);
return ret;
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, location);
- bool ret = diagnostic_impl (&richloc, NULL, opt, gmsgid, &ap, DK_PEDWARN);
+ bool ret = global_dc->diagnostic_impl (&richloc, nullptr, opt, gmsgid, &ap,
+ DK_PEDWARN);
va_end (ap);
return ret;
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- bool ret = diagnostic_impl (richloc, NULL, opt, gmsgid, &ap, DK_PEDWARN);
+ bool ret = global_dc->diagnostic_impl (richloc, nullptr, opt, gmsgid, &ap,
+ DK_PEDWARN);
va_end (ap);
return ret;
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, location);
- bool ret = diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_PERMERROR);
+ bool ret = global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap,
+ DK_PERMERROR);
va_end (ap);
return ret;
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- bool ret = diagnostic_impl (richloc, NULL, -1, gmsgid, &ap, DK_PERMERROR);
+ bool ret = global_dc->diagnostic_impl (richloc, nullptr, -1, gmsgid, &ap,
+ DK_PERMERROR);
va_end (ap);
return ret;
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, location);
- bool ret = diagnostic_impl (&richloc, NULL, opt, gmsgid, &ap, DK_PERMERROR);
+ bool ret = global_dc->diagnostic_impl (&richloc, nullptr, opt, gmsgid, &ap,
+ DK_PERMERROR);
va_end (ap);
return ret;
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- bool ret = diagnostic_impl (richloc, NULL, opt, gmsgid, &ap, DK_PERMERROR);
+ bool ret = global_dc->diagnostic_impl (richloc, nullptr, opt, gmsgid, &ap,
+ DK_PERMERROR);
va_end (ap);
return ret;
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, input_location);
- diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_ERROR);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_ERROR);
va_end (ap);
}
va_list ap;
va_start (ap, plural_gmsgid);
rich_location richloc (line_table, location);
- diagnostic_n_impl (&richloc, NULL, -1, n, singular_gmsgid, plural_gmsgid,
- &ap, DK_ERROR);
+ global_dc->diagnostic_n_impl (&richloc, nullptr, -1, n,
+ singular_gmsgid, plural_gmsgid,
+ &ap, DK_ERROR);
va_end (ap);
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, loc);
- diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_ERROR);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_ERROR);
va_end (ap);
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- diagnostic_impl (richloc, NULL, -1, gmsgid, &ap, DK_ERROR);
+ global_dc->diagnostic_impl (richloc, nullptr, -1, gmsgid, &ap, DK_ERROR);
va_end (ap);
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- diagnostic_impl (richloc, &metadata, -1, gmsgid, &ap, DK_ERROR);
+ global_dc->diagnostic_impl (richloc, &metadata, -1, gmsgid, &ap, DK_ERROR);
va_end (ap);
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, input_location);
- diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_SORRY);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_SORRY);
va_end (ap);
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, loc);
- diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_SORRY);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_SORRY);
va_end (ap);
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, loc);
- diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_FATAL);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_FATAL);
va_end (ap);
gcc_unreachable ();
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, input_location);
- diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_ICE);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_ICE);
va_end (ap);
gcc_unreachable ();
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, input_location);
- diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_ICE_NOBT);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_ICE_NOBT);
va_end (ap);
gcc_unreachable ();
label_text get_location_text (const expanded_location &s) const;
+ bool diagnostic_impl (rich_location *, const diagnostic_metadata *,
+ int, const char *,
+ va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0);
+ bool diagnostic_n_impl (rich_location *, const diagnostic_metadata *,
+ int, unsigned HOST_WIDE_INT,
+ const char *, const char *, va_list *,
+ diagnostic_t) ATTRIBUTE_GCC_DIAG(7,0);
+
private:
bool includes_seen_p (const line_map_ordinary *map);
printing them via a note otherwise e.g.:
gcc_rich_location richloc (primary_loc);
- bool added secondary = richloc.add_location_if_nearby (secondary_loc);
+ bool added secondary = richloc.add_location_if_nearby (*global_dc,
+ secondary_loc);
error_at (&richloc, "main message");
if (!added secondary)
inform (secondary_loc, "message for secondary");
Implemented in diagnostic-show-locus.cc. */
- bool add_location_if_nearby (location_t loc,
+ bool add_location_if_nearby (const diagnostic_context &ctxt,
+ location_t loc,
bool restrict_to_current_line_spans = true,
const range_label *label = NULL);