aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2000-07-02 10:56:57 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2000-07-02 10:56:57 +0200
commitfb753f88e9ae5a80d1499596821d3b09fd09cc7c (patch)
treee1e29855a5797315304e8491a4cfdf4286a2a7d9 /gcc
parent970d6386ebf7ea8f38b5f07623851e2f05ae5b2c (diff)
downloadgcc-fb753f88e9ae5a80d1499596821d3b09fd09cc7c.zip
gcc-fb753f88e9ae5a80d1499596821d3b09fd09cc7c.tar.gz
gcc-fb753f88e9ae5a80d1499596821d3b09fd09cc7c.tar.bz2
cpplib.h (struct cpp_reader): New field include_depth.
* 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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/cppfiles.c1
-rw-r--r--gcc/cppinit.c2
-rw-r--r--gcc/cpplex.c33
-rw-r--r--gcc/cpplib.h5
5 files changed, 37 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 96e16c7..fad11bd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c
index 4e14aae..4def8ed 100644
--- a/gcc/cppfiles.c
+++ b/gcc/cppfiles.c
@@ -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;
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index 0cbccae..320dfdb 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -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);
}
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index b7f6da5..109e97e 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -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
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index 88efdf7..b14bb78 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -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 */
};