OSDN Git Service

2008-07-03 H.J. Lu <hongjiu.lu@intel.com>
[pf3gnuchains/gcc-fork.git] / libcpp / errors.c
index 97de490..5e8e637 100644 (file)
@@ -1,6 +1,6 @@
 /* Default error handlers for CPP Library.
    Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1998, 1999, 2000,
-   2001, 2002, 2004 Free Software Foundation, Inc.
+   2001, 2002, 2004, 2008 Free Software Foundation, Inc.
    Written by Per Bothner, 1994.
    Based on CCCP program by Paul Rubin, June 1986
    Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -76,7 +76,7 @@ print_location (cpp_reader *pfile, source_location line, unsigned int col)
    big enough max_column_hint.)
 
    Returns 0 if the error has been suppressed.  */
-int
+static int
 _cpp_begin_message (cpp_reader *pfile, int code,
                    source_location src_loc, unsigned int column)
 {
@@ -151,6 +151,15 @@ cpp_error (cpp_reader * pfile, int level, const char *msgid, ...)
          else
            src_loc = pfile->line_table->highest_line;
        }
+      /* We don't want to refer to a token before the beginning of the
+        current run -- that is invalid.  */
+      else if (pfile->cur_token == pfile->cur_run->base)
+       {
+         if (pfile->cur_run->prev != NULL)
+           src_loc = pfile->cur_run->prev->limit->src_loc;
+         else
+           src_loc = 0;
+       }
       else
        {
          src_loc = pfile->cur_token[-1].src_loc;