]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* cppfiles.c (stack_include_file): line-map.c now handles include
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Aug 2001 23:05:12 +0000 (23:05 +0000)
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Aug 2001 23:05:12 +0000 (23:05 +0000)
depth.
(handle_missing_handler): Similarly.
(_cpp_execute_include): Similarly.
(_cpp_pop_file_buffer): Similarly.
* cpphash.h (struct cpp_reader): Remove system_include_depth,
buffer_stack_depth and include_depth.
* cpplib.c (do_include_common): line-map.c now handles include depth.
(cpp_push_buffer): Similarly.
(_cpp_pop_buffer): Similarly.
* cppmacro.c (builtin_macro): Update.
* line-map.c (init_line_maps): Set depth.
(add_line_map): Increment "used" earlier.  Update and use the
include depth.
(trace_include): Use the include depth.
* line-map.h (struct line_maps): New member depth.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45085 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cppfiles.c
gcc/cpphash.h
gcc/cpplib.c
gcc/cppmacro.c
gcc/line-map.c
gcc/line-map.h

index 04b2d0c5850a7b9f2fb0e8b68fd3cc15cf9d4a88..11a33645eb7243383686088fba9f874e084281bf 100644 (file)
@@ -1,3 +1,22 @@
+2001-08-22  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * cppfiles.c (stack_include_file): line-map.c now handles include
+       depth.
+       (handle_missing_handler): Similarly.
+       (_cpp_execute_include): Similarly.
+       (_cpp_pop_file_buffer): Similarly.
+       * cpphash.h (struct cpp_reader): Remove system_include_depth,
+       buffer_stack_depth and include_depth.
+       * cpplib.c (do_include_common): line-map.c now handles include depth.
+       (cpp_push_buffer): Similarly.
+       (_cpp_pop_buffer): Similarly.
+       * cppmacro.c (builtin_macro): Update.
+       * line-map.c (init_line_maps): Set depth.
+       (add_line_map): Increment "used" earlier.  Update and use the
+       include depth.
+       (trace_include): Use the include depth.
+       * line-map.h (struct line_maps): New member depth.
+
 2001-08-21  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * cppfiles.c (stack_include_file): Don't handle -H here.
index 1d60d3672579f581398991210be54f121bb46259..c8b28f947442707e24c624d9814e91e1879e1c9a 100644 (file)
@@ -324,7 +324,6 @@ stack_include_file (pfile, inc)
   /* Initialise controlling macro state.  */
   pfile->mi_valid = true;
   pfile->mi_cmacro = 0;
-  pfile->include_depth++;
 
   /* Generate the call back.  */
   filename = inc->name;
@@ -614,9 +613,7 @@ handle_missing_header (pfile, fname, angle_brackets)
      const char *fname;
      int angle_brackets;
 {
-  /* We will try making the RHS pfile->buffer->sysp after 3.0.  */
-  int print_dep = CPP_PRINT_DEPS(pfile) > (angle_brackets
-                                          || pfile->system_include_depth);
+  int print_dep = CPP_PRINT_DEPS(pfile) > (angle_brackets || pfile->map->sysp);
 
   if (CPP_OPTION (pfile, print_deps_missing_files) && print_dep)
     {
@@ -671,9 +668,6 @@ _cpp_execute_include (pfile, header, type)
                           header->type == CPP_HEADER_NAME);
   else if (inc != NO_INCLUDE_PATH)
     {
-      if (header->type == CPP_HEADER_NAME)
-       pfile->system_include_depth++;
-
       stacked = stack_include_file (pfile, inc);
 
       if (type == IT_IMPORT)
@@ -734,11 +728,6 @@ _cpp_pop_file_buffer (pfile, buf)
 {
   struct include_file *inc = buf->inc;
 
-  if (pfile->system_include_depth)
-    pfile->system_include_depth--;
-  if (pfile->include_depth)
-    pfile->include_depth--;
-
   /* Record the inclusion-preventing macro, which could be NULL
      meaning no controlling macro.  */
   if (pfile->mi_valid && inc->cmacro == NULL)
index 908040a69480384f0af00f32f301a568159246da..d9ebb983f094f7d4f37337d48f04cc9c43cfd20d 100644 (file)
@@ -279,15 +279,6 @@ struct cpp_reader
   unsigned char *macro_buffer;
   unsigned int macro_buffer_len;
 
-  /* Current depth in #include directives that use <...>.  */
-  unsigned int system_include_depth;
-
-  /* Current depth of buffer stack.  */
-  unsigned int buffer_stack_depth;
-
-  /* Current depth in #include directives.  */
-  unsigned int include_depth;
-
   /* Tree of other included files.  See cppfiles.c.  */
   struct splay_tree_s *all_include_files;
 
index e02ab696c85c57325e68c2d8368c56f09b181f42..6b1c11185fc83eaf451ff4c9035e034fbce37220 100644 (file)
@@ -614,7 +614,7 @@ do_include_common (pfile, type)
   if (!parse_include (pfile, &header))
     {
       /* Prevent #include recursion.  */
-      if (pfile->buffer_stack_depth >= CPP_STACK_MAX)
+      if (pfile->line_maps.depth >= CPP_STACK_MAX)
        cpp_fatal (pfile, "#include nested too deeply");
       else
        {
@@ -1764,7 +1764,6 @@ cpp_push_buffer (pfile, buffer, len, type, return_at_eof)
   new->pfile = pfile;
   new->return_at_eof = return_at_eof;
 
-  pfile->buffer_stack_depth++;
   pfile->buffer = new;
 
   return new;
@@ -1788,7 +1787,6 @@ _cpp_pop_buffer (pfile)
 
   /* Update the reader's buffer before _cpp_do_file_change.  */
   pfile->buffer = buffer->prev;
-  pfile->buffer_stack_depth--;
 
   if (buffer->type == BUF_FILE)
     {
index bc12913d8a64400f180c3f38be49dad4c1feebf1..1ee91b7b305c5aaf290617d33c92397c41cd5546 100644 (file)
@@ -164,10 +164,10 @@ builtin_macro (pfile, token)
       break;
        
     case BT_INCLUDE_LEVEL:
-      /* pfile->include_depth counts the primary source as level 1,
-        but historically __INCLUDE_DEPTH__ has called the primary
-        source level 0.  */
-      make_number_token (pfile, token, pfile->include_depth - 1);
+      /* The line map depth counts the primary source as level 1, but
+        historically __INCLUDE_DEPTH__ has called the primary source
+        level 0.  */
+      make_number_token (pfile, token, pfile->line_maps.depth - 1);
       break;
 
     case BT_SPECLINE:
index b2809b1510c8ee4f861b481ad645c76476675d34..a0f3ee50bc0fb640e2e9264134d529fe8194a23f 100644 (file)
@@ -39,6 +39,7 @@ init_line_maps (set)
   set->used = 0;
   set->last_listed = -1;
   set->trace_includes = false;
+  set->depth = 0;
 }
 
 /* Free a line map set.  */
@@ -90,11 +91,11 @@ add_line_map (set, reason, sysp, from_line, to_file, to_line)
        xrealloc (set->maps, set->allocated * sizeof (struct line_map));
     }
 
-  map = &set->maps[set->used];
+  map = &set->maps[set->used++];
 
   /* If we don't keep our line maps consistent, we can easily
      segfault.  Don't rely on the client to do it for us.  */
-  if (set->used == 0)
+  if (set->depth == 0)
     reason = LC_ENTER;
   else if (reason == LC_LEAVE)
     {
@@ -135,15 +136,19 @@ add_line_map (set, reason, sysp, from_line, to_file, to_line)
   map->to_line = to_line;
 
   if (reason == LC_ENTER)
-    map->included_from = set->used - 1;
+    {
+      set->depth++;
+      map->included_from = set->used - 2;
+      if (set->trace_includes)
+       trace_include (set, map);
+    }
   else if (reason == LC_RENAME)
     map->included_from = map[-1].included_from;
   else if (reason == LC_LEAVE)
-    map->included_from = INCLUDED_FROM (set, map - 1)->included_from;
-  set->used++;
-
-  if (reason == LC_ENTER && set->trace_includes)
-    trace_include (set, map);
+    {
+      set->depth--;
+      map->included_from = INCLUDED_FROM (set, map - 1)->included_from;
+    }
 
   return map;
 }
@@ -222,9 +227,9 @@ trace_include (set, map)
      const struct line_maps *set;
      const struct line_map *map;
 {
-  const struct line_map *m;
+  unsigned int i = set->depth;
 
-  for (m = map; !MAIN_FILE_P (m); m = INCLUDED_FROM (set, m))
+  while (--i)
     putc ('.', stderr);
   fprintf (stderr, " %s\n", map->to_file);
 }
index a226a1fdfc20501eb88ce7d00003097bcf3f87b7..835cb3177531f459d5a30026a49a32d72b026c53 100644 (file)
@@ -60,6 +60,9 @@ struct line_maps
      has been listed yet.  */
   int last_listed;
 
+  /* Depth of the include stack, including the current file.  */
+  unsigned int depth;
+
   /* If true, prints an include trace a la -H.  */
   bool trace_includes;
 };