Beispiel #1
0
/* Print the logical file location (LINE, COL) in preparation for a
   diagnostic.  Outputs the #include chain if it has changed.  A line
   of zero suppresses the include stack, and outputs the program name
   instead.  */
static void
print_location (cpp_reader *pfile, source_location line, unsigned int col)
{
  if (line == 0)
    fprintf (stderr, "%s: ", progname);
  else
    {
      const struct line_map *map;
      linenum_type lin;

      map = linemap_lookup (pfile->line_table, line);
      linemap_print_containing_files (pfile->line_table, map);

      lin = SOURCE_LINE (map, line);
      if (col == 0)
	{
	  col = SOURCE_COLUMN (map, line);
	  if (col == 0)
	    col = 1;
	}

      if (lin == 0)
	fprintf (stderr, "%s:", map->to_file);
      else if (CPP_OPTION (pfile, show_column) == 0)
	fprintf (stderr, "%s:%u:", map->to_file, lin);
      else
	fprintf (stderr, "%s:%u:%u:", map->to_file, lin, col);

      fputc (' ', stderr);
    }
}
Beispiel #2
0
/* Print the logical file location (LINE, COL) in preparation for a
   diagnostic.  Outputs the #include chain if it has changed.  A line
   of zero suppresses the include stack, and outputs the program name
   instead.  */
static void
print_location (cpp_reader *pfile, source_location line, unsigned int col)
{
  /* APPLE LOCAL begin error-colon */
  const char *estr;
  {
    static int done = 0;
    if ( ! done)
      {
        done = 1;       /* Do this only once.  */
        /* Pretend we saw "-w" on commandline.  */
        if (getenv ("GCC_DASH_W"))
          CPP_OPTION (pfile, inhibit_warnings) = 1; /* referenced by diagnostic.h:diagnostic_report_warnings() */
        if (getenv ("GCC_ERROR_COLON"))
          gcc_error_colon = 1;
      }
  }
  estr = (gcc_error_colon) ? "error:" : "" ;
  /* APPLE LOCAL end error-colon */

  if (line == 0)
    fprintf (stderr, "%s: ", progname);
  else
    {
      const struct line_map *map;
      unsigned int lin;

      map = linemap_lookup (pfile->line_table, line);
      linemap_print_containing_files (pfile->line_table, map);

      lin = SOURCE_LINE (map, line);
      if (col == 0)
	{
	  col = SOURCE_COLUMN (map, line);
	  if (col == 0)
	    col = 1;
	}

      /* APPLE LOCAL begin error-colon */
      if (lin == 0)
        fprintf (stderr, "%s:%s", map->to_file, estr);
      else if (CPP_OPTION (pfile, show_column) == 0)
        fprintf (stderr, "%s:%u:%s", map->to_file, lin, estr);
      else
        fprintf (stderr, "%s:%u:%u:%s", map->to_file, lin, col, estr);
      /* APPLE LOCAL end error-colon */

      fputc (' ', stderr);
    }
}