]> gcc.gnu.org Git - gcc.git/commitdiff
cpplib.h (struct cpp_reader): New field include_depth.
authorJakub Jelinek <jakub@redhat.com>
Sun, 2 Jul 2000 08:56:57 +0000 (10:56 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 2 Jul 2000 08:56:57 +0000 (10:56 +0200)
* cpplib.h (struct cpp_reader): New field include_depth.
(struct cpp_printer): Rename last_bsd to last_id.
* cppfiles.c (read_include_file): Bump include_depth.
* cpplex.c (cpp_pop_buffer): Decrement include_depth.
(output_line_command): Output correct #line if a header
is including itself and is not protected against multiple inclusion.
Use include_depth instead of buffer_stack_depth, last_id instead of
last_bsd.
* cppinit.c (cpp_start_read): Initialize last_id instead of
last_bsd.

From-SVN: r34831

gcc/ChangeLog
gcc/cppfiles.c
gcc/cppinit.c
gcc/cpplex.c
gcc/cpplib.h

index 96e16c78abc312098c4375cdbc29291faa2920a4..fad11bd56d135267fd124bd1f768954a2eec7f14 100644 (file)
@@ -1,3 +1,16 @@
+2000-07-02  Jakub Jelinek  <jakub@redhat.com>
+
+       * cpplib.h (struct cpp_reader): New field include_depth.
+       (struct cpp_printer): Rename last_bsd to last_id.
+       * cppfiles.c (read_include_file): Bump include_depth.
+       * cpplex.c (cpp_pop_buffer): Decrement include_depth.
+       (output_line_command): Output correct #line if a header
+       is including itself and is not protected against multiple inclusion.
+       Use include_depth instead of buffer_stack_depth, last_id instead of
+       last_bsd.
+       * cppinit.c (cpp_start_read): Initialize last_id instead of
+       last_bsd.
+
 2000-07-01  Benjamin Chelf  <chelf@codesourcery.com>
 
        * Makefile.in (C_AND_OBJC_OBJS): Added c-semantics.o.
index 4e14aae102f9927268bc7203815dfe5fa80a7108..4def8edee4917cdf9e1c5ac9f9611408078c66e8 100644 (file)
@@ -618,6 +618,7 @@ read_include_file (pfile, inc)
   /* These must be set before prescan.  */
   fp->inc = inc;
   fp->nominal_fname = inc->name;
+  pfile->include_depth++;
   
   if (length == 0)
     inc->cmacro = NEVER_REREAD;
index 0cbccaedbd8ca476c369b944a3f61af486d44762..320dfdb953b48b5c5d0e798b1451de19216901c7 100644 (file)
@@ -951,7 +951,7 @@ cpp_start_read (pfile, print, fname)
     {
       print->lineno = 0;
       print->last_fname = CPP_BUFFER (pfile)->nominal_fname;
-      print->last_bsd = pfile->buffer_stack_depth;
+      print->last_id = pfile->include_depth;
       print->written = CPP_WRITTEN (pfile);
     }
 
index b7f6da5181b9196826a53c5e3d97bff7cc197192..109e97ef86ca5e48f1731955f2863ef7b10d20d9 100644 (file)
@@ -218,6 +218,8 @@ cpp_pop_buffer (pfile)
        free ((PTR) buf->buf);
       if (pfile->system_include_depth)
        pfile->system_include_depth--;
+      if (pfile->include_depth)
+       pfile->include_depth--;
       if (pfile->potential_control_macro)
        {
          if (buf->inc->cmacro != NEVER_REREAD)
@@ -289,25 +291,26 @@ output_line_command (pfile, print, line)
   if (CPP_OPTION (pfile, no_line_commands))
     return;
 
-  /* Determine whether the current filename has changed, and if so,
-     how.  'nominal_fname' values are unique, so they can be compared
-     by comparing pointers.  */
-  if (ip->nominal_fname == print->last_fname)
-    change = same;
-  else
+  if (pfile->include_depth == print->last_id)
     {
-      if (pfile->buffer_stack_depth == print->last_bsd)
+      /* Determine whether the current filename has changed, and if so,
+        how.  'nominal_fname' values are unique, so they can be compared
+        by comparing pointers.  */
+      if (ip->nominal_fname == print->last_fname)
+       change = same;
+      else
        change = rname;
+    }
+  else
+    {
+      if (pfile->include_depth > print->last_id)
+       change = enter;
       else
-       {
-         if (pfile->buffer_stack_depth > print->last_bsd)
-           change = enter;
-         else
-           change = leave;
-         print->last_bsd = pfile->buffer_stack_depth;
-       }
-      print->last_fname = ip->nominal_fname;
+       change = leave;
+      print->last_id = pfile->include_depth;
     }
+  print->last_fname = ip->nominal_fname;
+
   /* If the current file has not changed, we can output a few newlines
      instead if we want to increase the line number by a small amount.
      We cannot do this if print->lineno is zero, because that means we
index 88efdf789bb896da7bc3ec7a816c4cbc90083776..b14bb7870fe512a6796c8df26518155a0b6197ef 100644 (file)
@@ -492,6 +492,9 @@ struct cpp_reader
   /* Current depth of buffer stack. */
   unsigned int buffer_stack_depth;
 
+  /* Current depth in #include directives.  */
+  unsigned int include_depth;
+
   /* Hash table of macros and assertions.  See cpphash.c */
   struct htab *hashtab;
 
@@ -564,7 +567,7 @@ struct cpp_printer
 {
   FILE *outf;                  /* stream to write to */
   const char *last_fname;      /* previous file name */
-  unsigned int last_bsd;       /* did we just push? */
+  unsigned int last_id;                /* did we just push? */
   unsigned int lineno;         /* line currently being written */
   unsigned int written;                /* low water mark in token buffer */
 };
This page took 0.079484 seconds and 5 git commands to generate.