summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2000-05-02 16:09:12 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2000-05-02 16:09:12 +0000
commitd1678bc67c1a9a12253410e4f89a38f715f2a499 (patch)
tree90422d7ae261276adf06a32d02442c9b52f52170 /gcc
parent9805577e2777772efe3a3b2a9b163fedcd0127b9 (diff)
downloadgcc-d1678bc67c1a9a12253410e4f89a38f715f2a499.tar.gz
* cpplib.h (CPP_POP, parse_cleanup_t): Delete.
(cpp_buffer): Remove cleanup, seen_eof, manual_pop members. * cppfiles.c (file_cleanup): Delete. * cpphash.c (macro_cleanup): Delete. (collect_objlike_expansion, collect_funlike_expansion, macarg, scan_arguments): Remove CPP_POP case. * cpplex.c (null_cleanup): Delete. (cpp_pop_buffer): Do the work that was done in the cleanups here. Call _cpp_unwind_if_stack from here. (_cpp_expand_to_buffer, cpp_scan_buffer_nooutput, cpp_scan_buffer): Run until we see CPP_EOF and the top of stack is the buffer _below_ the one we stacked. (cpp_get_token): Always pop an exhausted buffer. Return CPP_EOF unless it's a macro buffer. Don't call _cpp_handle_eof. * cpplib.c (skip_if_group): Don't call cpp_get_token to increment the line number. (_cpp_handle_eof): Rename to _cpp_unwind_if_stack. * fix-header.c (read_scan_file) [parsing getchar()]: Run until we see CPP_EOF and the top of stack is the buffer _below_ the one we stacked. * scan-decls.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33611 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog27
-rw-r--r--gcc/cppfiles.c22
-rw-r--r--gcc/cpphash.c34
-rw-r--r--gcc/cpphash.h2
-rw-r--r--gcc/cpplex.c96
-rw-r--r--gcc/cpplib.c31
-rw-r--r--gcc/cpplib.h15
-rw-r--r--gcc/fix-header.c13
-rw-r--r--gcc/scan-decls.c17
9 files changed, 115 insertions, 142 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 369e05815c4..f983bc7249f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,30 @@
+2000-05-02 Zack Weinberg <zack@wolery.cumb.org>
+
+ * cpplib.h (CPP_POP, parse_cleanup_t): Delete.
+ (cpp_buffer): Remove cleanup, seen_eof, manual_pop members.
+
+ * cppfiles.c (file_cleanup): Delete.
+ * cpphash.c (macro_cleanup): Delete.
+ (collect_objlike_expansion, collect_funlike_expansion,
+ macarg, scan_arguments): Remove CPP_POP case.
+
+ * cpplex.c (null_cleanup): Delete.
+ (cpp_pop_buffer): Do the work that was done in the cleanups
+ here. Call _cpp_unwind_if_stack from here.
+ (_cpp_expand_to_buffer, cpp_scan_buffer_nooutput,
+ cpp_scan_buffer): Run until we see CPP_EOF and the top of
+ stack is the buffer _below_ the one we stacked.
+ (cpp_get_token): Always pop an exhausted buffer. Return
+ CPP_EOF unless it's a macro buffer. Don't call _cpp_handle_eof.
+ * cpplib.c (skip_if_group): Don't call cpp_get_token to
+ increment the line number.
+ (_cpp_handle_eof): Rename to _cpp_unwind_if_stack.
+
+ * fix-header.c (read_scan_file) [parsing getchar()]: Run until
+ we see CPP_EOF and the top of stack is the buffer _below_ the
+ one we stacked.
+ * scan-decls.c: Likewise.
+
2000-05-02 Andrew Haley <aph@cygnus.com>
* config/ia64/ia64.c (ia64_encode_section_info): Handle the case
diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c
index 8fb2e0ee05d..5ec9d14f476 100644
--- a/gcc/cppfiles.c
+++ b/gcc/cppfiles.c
@@ -42,7 +42,6 @@ static struct file_name_list *actual_directory
PARAMS ((cpp_reader *, const char *));
static unsigned int hash_IHASH PARAMS ((const void *));
static int eq_IHASH PARAMS ((const void *, const void *));
-static int file_cleanup PARAMS ((cpp_buffer *, cpp_reader *));
static int find_include_file PARAMS ((cpp_reader *, const char *,
struct file_name_list *,
IHASH **, int *));
@@ -194,24 +193,6 @@ make_IHASH (name, fname, path, hash, slot)
return ih;
}
-static int
-file_cleanup (pbuf, pfile)
- cpp_buffer *pbuf;
- cpp_reader *pfile;
-{
- if (pbuf->buf)
- free ((PTR) pbuf->buf);
- if (pfile->system_include_depth)
- pfile->system_include_depth--;
- if (pfile->potential_control_macro)
- {
- pbuf->ihash->control_macro = pfile->potential_control_macro;
- pfile->potential_control_macro = 0;
- }
- pfile->input_stack_listing_current = 0;
- return 0;
-}
-
/* Centralize calls to open(2) here. This provides a hook for future
changes which might, e.g. look for and open a precompiled version
of the header. It also means all the magic currently associated
@@ -639,7 +620,7 @@ _cpp_execute_include (pfile, fname, len, no_reinclude, search_start)
if (read_include_file (pfile, fd, ihash))
{
if (angle_brackets)
- pfile->system_include_depth++; /* Decremented in file_cleanup. */
+ pfile->system_include_depth++;
}
}
@@ -771,7 +752,6 @@ read_include_file (pfile, fd, ihash)
fp->system_header_p = ihash->foundhere->sysp;
fp->lineno = 1;
fp->line_base = fp->buf;
- fp->cleanup = file_cleanup;
/* The ->actual_dir field is only used when ignore_srcdir is not in effect;
see do_include */
diff --git a/gcc/cpphash.c b/gcc/cpphash.c
index 97ca109cbdd..6ad8350a69f 100644
--- a/gcc/cpphash.c
+++ b/gcc/cpphash.c
@@ -113,7 +113,6 @@ static int dump_hash_helper PARAMS ((void **, void *));
static void push_macro_expansion PARAMS ((cpp_reader *, const U_CHAR *,
int, HASHNODE *));
static int unsafe_chars PARAMS ((cpp_reader *, int, int));
-static int macro_cleanup PARAMS ((cpp_buffer *, cpp_reader *));
static enum cpp_ttype macarg PARAMS ((cpp_reader *, int));
static void special_symbol PARAMS ((cpp_reader *, HASHNODE *));
static int compare_defs PARAMS ((cpp_reader *,
@@ -332,22 +331,6 @@ _cpp_free_definition (h)
h->value.cpval = NULL;
}
-static int
-macro_cleanup (pbuf, pfile)
- cpp_buffer *pbuf;
- cpp_reader *pfile ATTRIBUTE_UNUSED;
-{
- HASHNODE *m = pbuf->macro;
-
- m->disabled = 0;
- if ((m->type == T_FMACRO && pbuf->buf != m->value.fdefn->expansion)
- || m->type == T_SPECLINE || m->type == T_FILE
- || m->type == T_BASE_FILE || m->type == T_INCLUDE_LEVEL
- || m->type == T_STDC)
- free ((PTR) pbuf->buf);
- return 0;
-}
-
/* Create pat nodes. */
static void
@@ -485,7 +468,6 @@ collect_objlike_expansion (pfile, list)
{
switch (list->tokens[i].type)
{
- case CPP_POP:
case CPP_EOF:
cpp_ice (pfile, "EOF in collect_expansion");
/* fall through */
@@ -576,7 +558,6 @@ collect_funlike_expansion (pfile, list, arglist, replacement)
len = list->tokens[i].val.name.len;
switch (token)
{
- case CPP_POP:
case CPP_EOF:
cpp_ice (pfile, "EOF in collect_expansion");
/* fall through */
@@ -1034,14 +1015,9 @@ macarg (pfile, rest_args)
switch (token)
{
case CPP_EOF:
+ /* We've hit end of file; this is an error.
+ Caller will report it. */
return token;
- case CPP_POP:
- /* If we've hit end of file, it's an error (reported by caller).
- Ditto if it's the end of cpp_expand_to_buffer text.
- If we've hit end of macro, just continue. */
- if (!CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile)))
- return token;
- break;
case CPP_OPEN_PAREN:
paren++;
break;
@@ -1361,7 +1337,7 @@ scan_arguments (pfile, defn, args, name)
}
else
token = macarg (pfile, 0);
- if (token == CPP_EOF || token == CPP_POP)
+ if (token == CPP_EOF)
cpp_error_with_line (pfile, start_line, start_column,
"unterminated macro call");
i++;
@@ -1663,6 +1639,9 @@ funlike_macroexpand (pfile, hp, args)
/* Now put the expansion on the input stack
so our caller will commence reading from it. */
push_macro_expansion (pfile, xbuf, totlen, hp);
+
+ /* Overload buffer->mapped to indicate that xbuf needs to be freed. */
+ CPP_BUFFER (pfile)->mapped = 1;
}
/* Return 1 iff a token ending in C1 followed directly by a token C2
@@ -1771,7 +1750,6 @@ push_macro_expansion (pfile, xbuf, len, hp)
return;
if (advance_cur)
mbuf->cur += 2;
- mbuf->cleanup = macro_cleanup;
mbuf->macro = hp;
mbuf->has_escapes = 1;
diff --git a/gcc/cpphash.h b/gcc/cpphash.h
index 855df3bf069..9512c7ac4d5 100644
--- a/gcc/cpphash.h
+++ b/gcc/cpphash.h
@@ -253,7 +253,7 @@ extern void _cpp_scan_line PARAMS ((cpp_reader *, cpp_toklist *));
/* In cpplib.c */
extern int _cpp_handle_directive PARAMS ((cpp_reader *));
-extern void _cpp_handle_eof PARAMS ((cpp_reader *));
+extern void _cpp_unwind_if_stack PARAMS ((cpp_reader *, cpp_buffer *));
extern void _cpp_check_directive PARAMS((cpp_toklist *, cpp_token *));
#endif
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 3feacd28170..517b3d98cf0 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -45,7 +45,6 @@ static int copy_comment PARAMS ((cpp_reader *, int));
static void skip_string PARAMS ((cpp_reader *, int));
static void parse_string PARAMS ((cpp_reader *, int));
static U_CHAR *find_position PARAMS ((U_CHAR *, U_CHAR *, unsigned long *));
-static int null_cleanup PARAMS ((cpp_buffer *, cpp_reader *));
static void null_warning PARAMS ((cpp_reader *, unsigned int));
static void safe_fwrite PARAMS ((cpp_reader *, const U_CHAR *,
@@ -77,14 +76,6 @@ _cpp_grow_token_buffer (pfile, n)
CPP_SET_WRITTEN (pfile, old_written);
}
-static int
-null_cleanup (pbuf, pfile)
- cpp_buffer *pbuf ATTRIBUTE_UNUSED;
- cpp_reader *pfile ATTRIBUTE_UNUSED;
-{
- return 0;
-}
-
/* Allocate a new cpp_buffer for PFILE, and push it on the input buffer stack.
If BUFFER != NULL, then use the LENGTH characters in BUFFER
as the new input buffer.
@@ -107,7 +98,6 @@ cpp_push_buffer (pfile, buffer, length)
new = (cpp_buffer *) xcalloc (1, sizeof (cpp_buffer));
new->if_stack = pfile->if_stack;
- new->cleanup = null_cleanup;
new->buf = new->cur = buffer;
new->rlimit = buffer + length;
new->prev = buf;
@@ -125,7 +115,32 @@ cpp_pop_buffer (pfile)
cpp_buffer *buf = CPP_BUFFER (pfile);
if (ACTIVE_MARK_P (pfile))
cpp_ice (pfile, "mark active in cpp_pop_buffer");
- (*buf->cleanup) (buf, pfile);
+
+ if (buf->ihash)
+ {
+ _cpp_unwind_if_stack (pfile, buf);
+ if (buf->buf)
+ free ((PTR) buf->buf);
+ if (pfile->system_include_depth)
+ pfile->system_include_depth--;
+ if (pfile->potential_control_macro)
+ {
+ buf->ihash->control_macro = pfile->potential_control_macro;
+ pfile->potential_control_macro = 0;
+ }
+ pfile->input_stack_listing_current = 0;
+ }
+ else if (buf->macro)
+ {
+ HASHNODE *m = buf->macro;
+
+ m->disabled = 0;
+ if ((m->type == T_FMACRO && buf->mapped)
+ || m->type == T_SPECLINE || m->type == T_FILE
+ || m->type == T_BASE_FILE || m->type == T_INCLUDE_LEVEL
+ || m->type == T_STDC)
+ free ((PTR) buf->buf);
+ }
CPP_BUFFER (pfile) = CPP_PREV_BUFFER (buf);
free (buf);
pfile->buffer_stack_depth--;
@@ -321,7 +336,7 @@ _cpp_expand_to_buffer (pfile, buf, length)
const U_CHAR *buf;
int length;
{
- cpp_buffer *ip;
+ cpp_buffer *stop;
enum cpp_ttype token;
U_CHAR *buf1;
@@ -338,33 +353,27 @@ _cpp_expand_to_buffer (pfile, buf, length)
memcpy (buf1, buf, length);
/* Set up the input on the input stack. */
- ip = cpp_push_buffer (pfile, buf1, length);
- if (ip == NULL)
+ stop = CPP_BUFFER (pfile);
+ if (cpp_push_buffer (pfile, buf1, length) == NULL)
return;
- ip->has_escapes = 1;
+ CPP_BUFFER (pfile)->has_escapes = 1;
/* Scan the input, create the output. */
for (;;)
{
token = cpp_get_token (pfile);
- if (token == CPP_EOF)
+ if (token == CPP_EOF && CPP_BUFFER (pfile) == stop)
break;
- if (token == CPP_POP && CPP_BUFFER (pfile) == ip)
- {
- cpp_pop_buffer (pfile);
- break;
- }
}
}
-/* Scan until CPP_BUFFER (PFILE) is exhausted, discarding output.
- Then pop the buffer. */
+/* Scan until CPP_BUFFER (PFILE) is exhausted, discarding output. */
void
cpp_scan_buffer_nooutput (pfile)
cpp_reader *pfile;
{
- cpp_buffer *buffer = CPP_BUFFER (pfile);
+ cpp_buffer *stop = CPP_PREV_BUFFER (CPP_BUFFER (pfile));
enum cpp_ttype token;
unsigned int old_written = CPP_WRITTEN (pfile);
/* In no-output mode, we can ignore everything but directives. */
@@ -373,45 +382,33 @@ cpp_scan_buffer_nooutput (pfile)
if (! pfile->only_seen_white)
_cpp_skip_rest_of_line (pfile);
token = cpp_get_token (pfile);
- if (token == CPP_EOF)
+ if (token == CPP_EOF && CPP_BUFFER (pfile) == stop)
break;
- if (token == CPP_POP && CPP_BUFFER (pfile) == buffer)
- {
- cpp_pop_buffer (pfile);
- break;
- }
}
CPP_SET_WRITTEN (pfile, old_written);
}
-/* Scan until CPP_BUFFER (pfile) is exhausted, writing output to PRINT.
- Then pop the buffer. */
+/* Scan until CPP_BUFFER (pfile) is exhausted, writing output to PRINT. */
void
cpp_scan_buffer (pfile, print)
cpp_reader *pfile;
cpp_printer *print;
{
- cpp_buffer *buffer = CPP_BUFFER (pfile);
+ cpp_buffer *stop = CPP_PREV_BUFFER (CPP_BUFFER (pfile));
enum cpp_ttype token;
for (;;)
{
token = cpp_get_token (pfile);
- if ((token == CPP_POP && !CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile)))
- || token == CPP_EOF || token == CPP_VSPACE
+ if (token == CPP_EOF || token == CPP_VSPACE
/* XXX Temporary kluge - force flush after #include only */
|| (token == CPP_DIRECTIVE
&& CPP_BUFFER (pfile)->nominal_fname != print->last_fname))
{
cpp_output_tokens (pfile, print);
- if (token == CPP_EOF)
+ if (token == CPP_EOF && CPP_BUFFER (pfile) == stop)
return;
- if (token == CPP_POP && CPP_BUFFER (pfile) == buffer)
- {
- cpp_pop_buffer (pfile);
- return;
- }
}
}
}
@@ -1611,21 +1608,13 @@ cpp_get_token (pfile)
case CPP_EOF:
if (CPP_BUFFER (pfile) == NULL)
return CPP_EOF;
- if (CPP_BUFFER (pfile)->manual_pop)
- /* If we've been reading from redirected input, the
- frontend will pop the buffer. */
- return CPP_EOF;
-
- if (CPP_BUFFER (pfile)->seen_eof)
+ if (CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile)))
{
cpp_pop_buffer (pfile);
goto get_next;
}
- else
- {
- _cpp_handle_eof (pfile);
- return CPP_POP;
- }
+ cpp_pop_buffer (pfile);
+ return CPP_EOF;
}
}
@@ -1646,8 +1635,7 @@ cpp_get_non_space_token (pfile)
}
/* Like cpp_get_token, except that it does not execute directives,
- does not consume vertical space, discards horizontal space, and
- automatically pops off macro buffers. */
+ does not consume vertical space, and discards horizontal space. */
enum cpp_ttype
_cpp_get_directive_token (pfile)
cpp_reader *pfile;
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index d51c0b39e11..f96da23b83c 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -215,8 +215,8 @@ _cpp_handle_directive (pfile)
return 0;
if (CPP_PEDANTIC (pfile)
- && ! CPP_OPTION (pfile, preprocessed)
- && ! CPP_BUFFER (pfile)->manual_pop)
+ && CPP_BUFFER (pfile)->ihash
+ && ! CPP_OPTION (pfile, preprocessed))
cpp_pedwarn (pfile, "# followed by integer");
do_line (pfile);
return 1;
@@ -1345,14 +1345,17 @@ skip_if_group (pfile)
pfile->no_macro_expand++;
for (;;)
{
- /* We are at the end of a line. Only cpp_get_token knows how to
- advance the line number correctly. */
- token = cpp_get_token (pfile);
- if (token == CPP_POP)
+ /* We are at the end of a line.
+ XXX Serious layering violation here. */
+ int c = CPP_BUF_PEEK (CPP_BUFFER (pfile));
+ if (c == EOF)
break; /* Caller will issue error. */
- else if (token != CPP_VSPACE)
- cpp_ice (pfile, "cpp_get_token returned %d in skip_if_group", token);
+ else if (c != '\n')
+ cpp_ice (pfile, "character %c at end of line in skip_if_group", c);
+ CPP_BUFFER (pfile)->cur++;
+ CPP_BUMP_LINE (pfile);
CPP_SET_WRITTEN (pfile, old_written);
+ pfile->only_seen_white = 1;
token = _cpp_get_directive_token (pfile);
@@ -1458,15 +1461,18 @@ validate_else (pfile, directive)
pfile->no_macro_expand--;
}
+/* Called when we reach the end of a macro buffer. Walk back up the
+ conditional stack till we reach its level at entry to this file,
+ issuing error messages. */
void
-_cpp_handle_eof (pfile)
+_cpp_unwind_if_stack (pfile, pbuf)
cpp_reader *pfile;
+ cpp_buffer *pbuf;
{
struct if_stack *ifs, *nifs;
- /* Unwind the conditional stack and generate error messages. */
for (ifs = pfile->if_stack;
- ifs != CPP_BUFFER (pfile)->if_stack;
+ ifs != pbuf->if_stack;
ifs = nifs)
{
cpp_error_with_line (pfile, ifs->lineno, 0,
@@ -1477,7 +1483,6 @@ _cpp_handle_eof (pfile)
free (ifs);
}
pfile->if_stack = ifs;
- CPP_BUFFER (pfile)->seen_eof = 1;
}
static int
@@ -1658,7 +1663,7 @@ cpp_undef (pfile, macro)
memcpy (buf, macro, len);
buf[len] = '\n';
buf[len + 1] = '\0';
- if (cpp_push_buffer (pfile, buf, len + 1))
+ if (cpp_push_buffer (pfile, buf, len + 1) != NULL)
{
do_undef (pfile);
cpp_pop_buffer (pfile);
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index c635ff64460..4d005df0931 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -131,7 +131,6 @@ typedef struct cpp_name cpp_name;
/* Obsolete - will be removed when no code uses them still. */ \
H(CPP_COMMENT, 0) /* Only if output comments. */ \
N(CPP_HSPACE, 0) /* Horizontal white space. */ \
- N(CPP_POP, 0) /* End of buffer. */ \
N(CPP_DIRECTIVE, 0) /* #define and the like */ \
N(CPP_MACRO, 0) /* Like a NAME, but expanded. */
@@ -192,7 +191,6 @@ struct cpp_token
#define SYNTAX_ASSERT (1 << 9)
typedef int (*directive_handler) PARAMS ((cpp_reader *));
-typedef int (*parse_cleanup_t) PARAMS ((cpp_buffer *, cpp_reader *));
struct cpp_toklist
{
@@ -238,8 +236,6 @@ struct cpp_buffer
to record control macros. */
struct ihash *ihash;
- parse_cleanup_t cleanup;
-
/* If the buffer is the expansion of a macro, this points to the
macro's hash table entry. */
struct hashnode *macro;
@@ -254,9 +250,6 @@ struct cpp_buffer
/* True if this is a header file included using <FILENAME>. */
char system_header_p;
- /* True if end-of-file has already been hit once in this buffer. */
- char seen_eof;
-
/* True if buffer contains escape sequences.
Currently there are two kinds:
"\r-" means following identifier should not be macro-expanded.
@@ -271,17 +264,15 @@ struct cpp_buffer
from macro expansion text in collect_expansion and/or macarg. */
char has_escapes;
- /* Used by the C++ frontend to implement redirected input (such as for
- default argument and/or template parsing). */
- char manual_pop;
-
/* True if we have already warned about C++ comments in this file.
The warning happens only for C89 extended mode with -pedantic on,
or for -Wtraditional, and only once per file (otherwise it would
be far too noisy). */
char warned_cplusplus_comments;
- /* True if this buffer's data is mmapped. */
+ /* In a file buffer, true if this buffer's data is mmapped
+ (currently never the case). In a macro buffer, true if this
+ buffer's data must be freed. */
char mapped;
};
diff --git a/gcc/fix-header.c b/gcc/fix-header.c
index 29b4d355c6d..3740ce05ca9 100644
--- a/gcc/fix-header.c
+++ b/gcc/fix-header.c
@@ -658,10 +658,12 @@ read_scan_file (in_fname, argc, argv)
&& (fn = lookup_std_proto ("_filbuf", 7)) != NULL)
{
static char getchar_call[] = "getchar();";
- cpp_buffer *buf
- = cpp_push_buffer (&scan_in, getchar_call, sizeof(getchar_call) - 1);
int old_written = CPP_WRITTEN (&scan_in);
int seen_filbuf = 0;
+ cpp_buffer *buf = CPP_BUFFER (&scan_in);
+ if (cpp_push_buffer (&scan_in, getchar_call,
+ sizeof(getchar_call) - 1) == NULL)
+ return;
/* Scan the macro expansion of "getchar();". */
for (;;)
@@ -671,13 +673,8 @@ read_scan_file (in_fname, argc, argv)
unsigned char *id = scan_in.token_buffer + old_written;
CPP_SET_WRITTEN (&scan_in, old_written);
- if (token == CPP_EOF) /* Should not happen ... */
+ if (token == CPP_EOF && CPP_BUFFER (&scan_in) == buf)
break;
- if (token == CPP_POP && CPP_BUFFER (&scan_in) == buf)
- {
- cpp_pop_buffer (&scan_in);
- break;
- }
if (token == CPP_NAME && cpp_idcmp (id, length, "_filbuf") == 0)
seen_filbuf++;
}
diff --git a/gcc/scan-decls.c b/gcc/scan-decls.c
index 8953da57859..e65d832fda0 100644
--- a/gcc/scan-decls.c
+++ b/gcc/scan-decls.c
@@ -116,7 +116,12 @@ scan_decls (pfile, argc, argv)
goto new_statement;
}
if (token == CPP_EOF)
- return 0;
+ {
+ if (CPP_BUFFER (pfile) == NULL)
+ return 0;
+ else
+ goto new_statement;
+ }
if (token == CPP_SEMICOLON)
goto new_statement;
if (token != CPP_NAME)
@@ -235,13 +240,15 @@ scan_decls (pfile, argc, argv)
prev_id_end = CPP_WRITTEN (pfile);
break;
- case CPP_EOF:
- return 0;
-
case CPP_OPEN_BRACE: case CPP_CLOSE_BRACE: case CPP_DIRECTIVE:
goto new_statement; /* handle_statement? */
- case CPP_HSPACE: case CPP_VSPACE: case CPP_COMMENT: case CPP_POP:
+ case CPP_EOF:
+ if (CPP_BUFFER (pfile) == NULL)
+ return 0;
+ /* else fall through */
+
+ case CPP_HSPACE: case CPP_VSPACE: case CPP_COMMENT:
/* Skip initial white space. */
if (start_written == 0)
CPP_SET_WRITTEN (pfile, 0);