richloc.add_range (param, SHOW_RANGE_WITHOUT_CARET, ¶m_label);
test_diagnostic_context dc;
- diagnostic_show_locus (&dc, &richloc, DK_ERROR);
+ diagnostic_show_locus (&dc, &richloc, DK_ERROR, dc.m_printer);
if (c_dialect_cxx ())
/* "char*", without a space. */
ASSERT_STREQ (" printf (\"msg: %i\\n\", msg);\n"
void
diagnostic_context::maybe_show_locus (const rich_location &richloc,
diagnostic_t diagnostic_kind,
- pretty_printer *pp,
+ pretty_printer &pp,
diagnostic_source_effect_info *effects)
{
const location_t loc = richloc.get_loc ();
m_last_location = loc;
- if (!pp)
- pp = m_printer;
- gcc_assert (pp);
-
diagnostic_source_print_policy source_policy (*this);
- source_policy.print (*pp, richloc, diagnostic_kind, effects);
+ source_policy.print (pp, richloc, diagnostic_kind, effects);
}
diagnostic_source_print_policy::
void maybe_show_locus (const rich_location &richloc,
diagnostic_t diagnostic_kind,
- pretty_printer *pp,
+ pretty_printer &pp,
diagnostic_source_effect_info *effect_info);
void emit_diagram (const diagnostic_diagram &diagram);
diagnostic_show_locus (diagnostic_context *context,
rich_location *richloc,
diagnostic_t diagnostic_kind,
- pretty_printer *pp = nullptr,
+ pretty_printer *pp,
diagnostic_source_effect_info *effect_info = nullptr)
{
+ gcc_assert (context);
gcc_assert (richloc);
- context->maybe_show_locus (*richloc, diagnostic_kind, pp, effect_info);
+ gcc_assert (pp);
+ context->maybe_show_locus (*richloc, diagnostic_kind, *pp, effect_info);
}
/* Because we read source files a second time after the frontend did it the
{
/* Run the diagnostic and fix-it printing code. */
test_diagnostic_context dc;
- diagnostic_show_locus (&dc, richloc, DK_ERROR);
+ diagnostic_show_locus (&dc, richloc, DK_ERROR, dc.m_printer);
/* Generate a diff. */
edit_context ec (global_dc->get_file_cache ());