OSDN Git Service

* expr.c (highest_pow2_factor_for_type): Rename into
[pf3gnuchains/gcc-fork.git] / gcc / cpplib.c
index 33b2de6..f2556b3 100644 (file)
@@ -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,7 +856,8 @@ 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;
@@ -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_table, 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);
@@ -1340,7 +1347,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 +1909,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_table;
-}
-
 /* Copy the given callbacks structure to our own.  */
 void
 cpp_set_callbacks (cpp_reader *pfile, cpp_callbacks *cb)
@@ -1925,7 +1924,6 @@ cpp_push_buffer (cpp_reader *pfile, const uchar *buffer, size_t len,
                 int from_stage3)
 {
   cpp_buffer *new = xobnew (&pfile->buffer_ob, cpp_buffer);
-  const char *input = CPP_OPTION (pfile, input_charset);
 
   /* Clears, amongst other things, if_stack and mi_cmacro.  */
   memset (new, 0, sizeof (cpp_buffer));
@@ -1937,7 +1935,6 @@ cpp_push_buffer (cpp_reader *pfile, const uchar *buffer, size_t len,
   new->need_line = true;
 
   pfile->buffer = new;
-  _cpp_init_iconv_buffer (pfile, input);
 
   return new;
 }
@@ -1960,8 +1957,6 @@ _cpp_pop_buffer (cpp_reader *pfile)
   /* In case of a missing #endif.  */
   pfile->state.skipping = 0;
 
-  _cpp_close_iconv_buffer (pfile);
-
   /* _cpp_do_file_change expects pfile->buffer to be the new one.  */
   pfile->buffer = buffer->prev;