diff options
author | Zack Weinberg <zack@wolery.cumb.org> | 2000-05-02 16:09:12 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-05-02 16:09:12 +0000 |
commit | c56c2073a6268960931acd0b852b6186d4bde179 (patch) | |
tree | 90422d7ae261276adf06a32d02442c9b52f52170 /gcc/cpplib.c | |
parent | 753e6cf1b64ccc2e8f7946d4a7a010f82ff99c31 (diff) | |
download | gcc-c56c2073a6268960931acd0b852b6186d4bde179.zip gcc-c56c2073a6268960931acd0b852b6186d4bde179.tar.gz gcc-c56c2073a6268960931acd0b852b6186d4bde179.tar.bz2 |
cpplib.h (CPP_POP, [...]): Delete.
* 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.
From-SVN: r33611
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r-- | gcc/cpplib.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c index d51c0b3..f96da23 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); |