aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpperror.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cpperror.c')
-rw-r--r--gcc/cpperror.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/gcc/cpperror.c b/gcc/cpperror.c
index 063489d..f101982 100644
--- a/gcc/cpperror.c
+++ b/gcc/cpperror.c
@@ -29,7 +29,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "cpphash.h"
#include "intl.h"
-static void print_containing_files PARAMS ((cpp_buffer *));
+static void print_containing_files PARAMS ((struct line_map *,
+ struct line_map *));
static void print_location PARAMS ((cpp_reader *,
const char *,
const cpp_lexer_pos *));
@@ -42,21 +43,25 @@ static void print_location PARAMS ((cpp_reader *,
/* Print the file names and line numbers of the #include
commands which led to the current file. */
static void
-print_containing_files (ip)
- cpp_buffer *ip;
+print_containing_files (map_array, map)
+ struct line_map *map_array;
+ struct line_map *map;
{
int first = 1;
- /* Find the other, outer source files. */
- for (ip = ip->prev; ip; ip = ip->prev)
+ for (;;)
{
+ if (MAIN_FILE_P (map))
+ break;
+ map = &map_array[map->included_from];
+
if (first)
{
first = 0;
/* The current line in each outer source file is now the
same as the line of the #include. */
fprintf (stderr, _("In file included from %s:%u"),
- ip->nominal_fname, CPP_BUF_LINE (ip));
+ map->to_file, LAST_SOURCE_LINE (map));
}
else
/* Translators note: this message is used in conjunction
@@ -72,8 +77,9 @@ print_containing_files (ip)
The trailing comma is at the beginning of this message,
and the trailing colon is not translated. */
fprintf (stderr, _(",\n from %s:%u"),
- ip->nominal_fname, CPP_BUF_LINE (ip));
+ map->to_file, LAST_SOURCE_LINE (map));
}
+
fputs (":\n", stderr);
}
@@ -100,19 +106,24 @@ print_location (pfile, filename, pos)
line = 0;
else
{
+ struct line_map *map;
+
+ line = pfile->line;
if (type == BUF_PRAGMA)
{
buffer = buffer->prev;
- line = CPP_BUF_LINE (buffer);
col = CPP_BUF_COL (buffer);
}
- else
+
+ map = lookup_line (&pfile->line_maps, line);
+ if (pos == 0)
{
- if (pos == 0)
- pos = cpp_get_line (pfile);
- line = pos->line;
- col = pos->col;
+ pos = cpp_get_line (pfile);
+ line = SOURCE_LINE (map, line);
}
+ else
+ line = pos->line;
+ col = pos->col;
if (col == 0)
col = 1;
@@ -121,7 +132,7 @@ print_location (pfile, filename, pos)
if (buffer->prev && ! buffer->include_stack_listed)
{
buffer->include_stack_listed = 1;
- print_containing_files (buffer);
+ print_containing_files (pfile->line_maps.maps, map);
}
}
@@ -129,14 +140,15 @@ print_location (pfile, filename, pos)
filename = buffer->nominal_fname;
if (line == 0)
- fprintf (stderr, "%s: ", filename);
+ fprintf (stderr, "%s:", filename);
else if (CPP_OPTION (pfile, show_column) == 0)
- fprintf (stderr, "%s:%u: ", filename, line);
+ fprintf (stderr, "%s:%u:", filename, line);
else
- fprintf (stderr, "%s:%u:%u: ", filename, line, col);
+ fprintf (stderr, "%s:%u:%u:", filename, line, col);
if (type == BUF_PRAGMA)
- fprintf (stderr, "_Pragma: ");
+ fprintf (stderr, "_Pragma:");
+ fputc (' ', stderr);
}
}