OSDN Git Service

PR optimization/13424 (hppa), bootstrap/14462, c/14828
[pf3gnuchains/gcc-fork.git] / gcc / cpplib.c
index 2b213cb..80adfb8 100644 (file)
@@ -1,6 +1,6 @@
 /* CPP Library. (Directive handling.)
    Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
    Contributed by Per Bothner, 1994-95.
    Based on CCCP program by Paul Rubin, June 1986
    Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -549,14 +549,14 @@ do_undef (cpp_reader *pfile)
 /* Undefine a single macro/assertion/whatever.  */
 
 static int
-undefine_macros (cpp_reader *pfile, cpp_hashnode *h, 
+undefine_macros (cpp_reader *pfile, cpp_hashnode *h,
                 void *data_p ATTRIBUTE_UNUSED)
 {
   switch (h->type)
     {
     case NT_VOID:
       break;
-      
+
     case NT_MACRO:
       if (pfile->cb.undef)
         (*pfile->cb.undef) (pfile, pfile->directive_line, h);
@@ -681,7 +681,7 @@ do_include_common (cpp_reader *pfile, enum include_type type)
     return;
 
   /* Prevent #include recursion.  */
-  if (pfile->line_maps.depth >= CPP_STACK_MAX)
+  if (pfile->line_table->depth >= CPP_STACK_MAX)
     cpp_error (pfile, CPP_DL_ERROR, "#include nested too deeply");
   else
     {
@@ -777,8 +777,9 @@ strtoul_for_line (const uchar *str, unsigned int len, long unsigned int *nump)
 static void
 do_line (cpp_reader *pfile)
 {
+  const struct line_map *map = linemap_lookup (pfile->line_table, pfile->line);
   const cpp_token *token;
-  const char *new_file = pfile->map->to_file;
+  const char *new_file = map->to_file;
   unsigned long new_lineno;
 
   /* C99 raised the minimum limit on #line numbers.  */
@@ -803,7 +804,8 @@ do_line (cpp_reader *pfile)
   if (token->type == CPP_STRING)
     {
       cpp_string s = { 0, 0 };
-      if (_cpp_interpret_string_notranslate (pfile, &token->val.str, &s))
+      if (cpp_interpret_string_notranslate (pfile, &token->val.str, 1,
+                                           &s, false))
        new_file = (const char *)s.text;
       check_eol (pfile);
     }
@@ -816,7 +818,7 @@ do_line (cpp_reader *pfile)
 
   skip_rest_of_line (pfile);
   _cpp_do_file_change (pfile, LC_RENAME, new_file, new_lineno,
-                      pfile->map->sysp);
+                      map->sysp);
 }
 
 /* Interpret the # 44 "file" [flags] notation, which has slightly
@@ -825,10 +827,11 @@ do_line (cpp_reader *pfile)
 static void
 do_linemarker (cpp_reader *pfile)
 {
+  const struct line_map *map = linemap_lookup (pfile->line_table, pfile->line);
   const cpp_token *token;
-  const char *new_file = pfile->map->to_file;
+  const char *new_file = map->to_file;
   unsigned long new_lineno;
-  unsigned int new_sysp = pfile->map->sysp;
+  unsigned int new_sysp = map->sysp;
   enum lc_reason reason = LC_RENAME;
   int flag;
 
@@ -853,9 +856,10 @@ do_linemarker (cpp_reader *pfile)
   if (token->type == CPP_STRING)
     {
       cpp_string s = { 0, 0 };
-      if (_cpp_interpret_string_notranslate (pfile, &token->val.str, &s))
+      if (cpp_interpret_string_notranslate (pfile, &token->val.str,
+                                           1, &s, false))
        new_file = (const char *)s.text;
-      
+
       new_sysp = 0;
       flag = read_flag (pfile, 0);
       if (flag == 1)
@@ -876,6 +880,7 @@ do_linemarker (cpp_reader *pfile)
          flag = read_flag (pfile, flag);
          if (flag == 4)
            new_sysp = 2;
+         pfile->buffer->sysp = new_sysp;
        }
 
       check_eol (pfile);
@@ -900,11 +905,15 @@ _cpp_do_file_change (cpp_reader *pfile, enum lc_reason reason,
                     const char *to_file, unsigned int file_line,
                     unsigned int sysp)
 {
-  pfile->map = linemap_add (&pfile->line_maps, reason, sysp,
-                           pfile->line, to_file, file_line);
+  const struct line_map *map = linemap_add (pfile->line_table, reason, sysp,
+                                           to_file, file_line);
+  if (map == NULL)
+    pfile->line = 0;
+  else
+    pfile->line = linemap_line_start (pfile->line_table, map->to_line, 127);
 
   if (pfile->cb.file_change)
-    pfile->cb.file_change (pfile, pfile->map);
+    pfile->cb.file_change (pfile, map);
 }
 
 /* Report a warning or error detected by the program we are
@@ -912,9 +921,7 @@ _cpp_do_file_change (cpp_reader *pfile, enum lc_reason reason,
 static void
 do_diagnostic (cpp_reader *pfile, int code, int print_dir)
 {
-  if (_cpp_begin_message (pfile, code,
-                         pfile->cur_token[-1].line,
-                         pfile->cur_token[-1].col))
+  if (_cpp_begin_message (pfile, code, pfile->cur_token[-1].src_loc, 0))
     {
       if (print_dir)
        fprintf (stderr, "#%s ", pfile->directive->name);
@@ -1157,9 +1164,6 @@ do_pragma (cpp_reader *pfile)
       if (pfile->cb.line_change)
        (*pfile->cb.line_change) (pfile, pragma_token, false);
       (*p->u.handler) (pfile);
-      if (pfile->cb.line_change)
-       (*pfile->cb.line_change) (pfile, pfile->cur_token, false);
-      
     }
   else if (pfile->cb.def_pragma)
     {
@@ -1340,7 +1344,6 @@ destringize_and_run (cpp_reader *pfile, const cpp_string *in)
     pfile->context = saved_context;
     pfile->cur_token = saved_cur_token;
     pfile->cur_run = saved_cur_run;
-    pfile->line--;
   }
 
   /* See above comment.  For the moment, we'd like
@@ -1903,13 +1906,6 @@ cpp_get_callbacks (cpp_reader *pfile)
   return &pfile->cb;
 }
 
-/* The line map set.  */
-const struct line_maps *
-cpp_get_line_maps (cpp_reader *pfile)
-{
-  return &pfile->line_maps;
-}
-
 /* Copy the given callbacks structure to our own.  */
 void
 cpp_set_callbacks (cpp_reader *pfile, cpp_callbacks *cb)
@@ -1936,6 +1932,7 @@ cpp_push_buffer (cpp_reader *pfile, const uchar *buffer, size_t len,
   new->need_line = true;
 
   pfile->buffer = new;
+
   return new;
 }