OSDN Git Service

* java/util/Hashtable.java (Enumerator): Ensure that if
[pf3gnuchains/gcc-fork.git] / gcc / cppinit.c
index 9e5fa8e..2cf7461 100644 (file)
@@ -511,6 +511,11 @@ cpp_create_reader (table, lang)
   /* Indicate date and time not yet calculated.  */
   pfile->date.type = CPP_EOF;
 
+  /* Create a token buffer for the lexer.  */
+  _cpp_init_tokenrun (&pfile->base_run, 250);
+  pfile->cur_run = &pfile->base_run;
+  pfile->cur_token = pfile->base_run.base;
+
   /* Initialise the base context.  */
   pfile->context = &pfile->base_context;
   pfile->base_context.macro = 0;
@@ -575,7 +580,6 @@ cpp_destroy (pfile)
 
   _cpp_destroy_hashtable (pfile);
   _cpp_cleanup_includes (pfile);
-  _cpp_free_lookaheads (pfile);
 
   _cpp_free_pool (&pfile->ident_pool);
   _cpp_free_pool (&pfile->macro_pool);
@@ -958,18 +962,19 @@ cpp_start_read (pfile, fname)
 
       /* Scan -imacros files after command line defines, but before
         files given with -include.  */
-      for (p = CPP_OPTION (pfile, pending)->imacros_head; p; p = p->next)
+      while ((p = CPP_OPTION (pfile, pending)->imacros_head) != NULL)
        {
          if (push_include (pfile, p))
            {
              pfile->buffer->return_at_eof = true;
              cpp_scan_nooutput (pfile);
            }
+         CPP_OPTION (pfile, pending)->imacros_head = p->next;
+         free (p);
        }
     }
 
   free_chain (CPP_OPTION (pfile, pending)->directive_head);
-  free_chain (CPP_OPTION (pfile, pending)->imacros_head);
   _cpp_push_next_buffer (pfile);
 
   return 1;
@@ -984,7 +989,12 @@ _cpp_push_next_buffer (pfile)
 {
   bool pushed = false;
 
-  if (CPP_OPTION (pfile, pending))
+  /* This is't pretty; we'd rather not be relying on this as a boolean
+     for reverting the line map.  Further, we only free the chains in
+     this conditional, so an early call to cpp_finish / cpp_destroy
+     will leak that memory.  */
+  if (CPP_OPTION (pfile, pending)
+      && CPP_OPTION (pfile, pending)->imacros_head == NULL)
     {
       while (!pushed)
        {
@@ -1020,7 +1030,8 @@ output_deps (pfile)
 {
   /* Stream on which to print the dependency information.  */
   FILE *deps_stream = 0;
-  const char *deps_mode = CPP_OPTION (pfile, print_deps_append) ? "a" : "w";
+  const char *const deps_mode =
+    CPP_OPTION (pfile, print_deps_append) ? "a" : "w";
 
   if (CPP_OPTION (pfile, deps_file) == 0)
     deps_stream = stdout;