Exemplo n.º 1
0
/* Prints out, if necessary, the name of the current function
   that caused an error.  Called from all error and warning functions.  */
void
diagnostic_report_current_function (diagnostic_context *context,
				    diagnostic_info *diagnostic)
{
  diagnostic_report_current_module (context, diagnostic_location (diagnostic));
  lang_hooks.print_error_function (context, LOCATION_FILE (input_location),
				   diagnostic);
}
Exemplo n.º 2
0
void
diagnostic_show_locus (diagnostic_context * context,
		       const diagnostic_info *diagnostic)
{
  pp_newline (context->printer);

  if (!context->show_caret
      || diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION
      || diagnostic_location (diagnostic, 0) == context->last_location)
    return;

  context->last_location = diagnostic_location (diagnostic, 0);

  const char *saved_prefix = pp_get_prefix (context->printer);
  pp_set_prefix (context->printer, NULL);

  layout layout (context, diagnostic);
  for (int line_span_idx = 0; line_span_idx < layout.get_num_line_spans ();
       line_span_idx++)
    {
      const line_span *line_span = layout.get_line_span (line_span_idx);
      if (layout.print_heading_for_line_span_index_p (line_span_idx))
	{
	  expanded_location exploc = layout.get_expanded_location (line_span);
	  context->start_span (context, exploc);
	}
      int last_line = line_span->get_last_line ();
      for (int row = line_span->get_first_line (); row <= last_line; row++)
	{
	  /* Print the source line, followed by an annotation line
	     consisting of any caret/underlines, then any fixits.
	     If the source line can't be read, print nothing.  */
	  line_bounds lbounds;
	  if (layout.print_source_line (row, &lbounds))
	    {
	      layout.print_annotation_line (row, lbounds);
	      layout.print_any_fixits (row, diagnostic->richloc);
	    }
	}
    }

  pp_set_prefix (context->printer, saved_prefix);
}
Exemplo n.º 3
0
static void
verify_no_columns  (diagnostic_context *context,
		    diagnostic_info *diagnostic)
{
  /* Verify that the locations have no columns. */
  location_t loc = diagnostic_location (diagnostic);
  gcc_assert (LOCATION_COLUMN (loc) == 0);

  /* We're done testing; chain up to original finalizer.  */
  gcc_assert (original_finalizer);
  original_finalizer (context, diagnostic);
}
Exemplo n.º 4
0
static void
verify_unpacked_ranges  (diagnostic_context *context,
			 diagnostic_info *diagnostic)
{
  /* Verify that the locations are ad-hoc, not packed. */
  location_t loc = diagnostic_location (diagnostic);
  gcc_assert (IS_ADHOC_LOC (loc));

  /* We're done testing; chain up to original finalizer.  */
  gcc_assert (original_finalizer);
  original_finalizer (context, diagnostic);
}