diff options
author | Zack Weinberg <zack@wolery.cumb.org> | 2000-09-12 03:42:30 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-09-12 03:42:30 +0000 |
commit | a58d32c208153b93994f6bc1a26dd35e4b58c994 (patch) | |
tree | b6a034134f9f646df618389e79a9becaa26938a5 /gcc/cpplex.c | |
parent | 4ba01ed2ae8beb00e653be369f423a452ed6f363 (diff) | |
download | gcc-a58d32c208153b93994f6bc1a26dd35e4b58c994.zip gcc-a58d32c208153b93994f6bc1a26dd35e4b58c994.tar.gz gcc-a58d32c208153b93994f6bc1a26dd35e4b58c994.tar.bz2 |
cppfiles.c: Move all default-#defines to top of file.
* cppfiles.c: Move all default-#defines to top of file.
(open_include_file): Replace by lookup_include_file.
(read_with_read, read_file): Merged into read_include_file.
(stack_include_file, purge_cache): New functions.
(close_cached_fd): Delete.
(lookup_include_file, read_include_file, _cpp_pop_file_buffer):
Cache the in-memory buffer, not the file descriptor.
* cpphash.h (struct include_file): Add buffer, st, refcnt,
mapped fields.
(xcnew): New utility macro.
(DO_NOT_REREAD, NEVER_REREAD): Move up by struct include_file.
* cpplib.h (struct cpp_buffer): Remove mapped field.
* cpplex.c (parse_string): Accept backslash space newline as a
line continuation.
(lex_line): Likewise.
(_cpp_get_token): Remove hard limit on macro nesting.
testsuite:
* gcc.dg/cpp/backslash.c: New test.
From-SVN: r36347
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r-- | gcc/cpplex.c | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c index ab5a987..5cb6b7f 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -1106,12 +1106,23 @@ parse_string (pfile, list, token, terminator) if (is_vspace (c)) { /* Drop a backslash newline, and continue. */ + U_CHAR *old = namebuf; + while (namebuf > list->namebuf && is_hspace (namebuf[-1])) + namebuf--; if (namebuf > list->namebuf && namebuf[-1] == '\\') { handle_newline (cur, buffer->rlimit, c); namebuf--; + if (old[-1] != '\\') + { + buffer->cur = cur; + cpp_warning (pfile, + "backslash and newline separated by space"); + } continue; } + else + namebuf = old; cur--; @@ -1516,37 +1527,40 @@ lex_line (pfile, list) handle_newline (cur, buffer->rlimit, c); if (PREV_TOKEN_TYPE == CPP_BACKSLASH) { - if (IMMED_TOKEN ()) - { - /* Remove the escaped newline. Then continue to process - any interrupted name or number. */ - cur_token--; - /* Backslash-newline may not be immediately followed by - EOF (C99 5.1.1.2). */ - if (cur >= buffer->rlimit) - { - cpp_pedwarn (pfile, "backslash-newline at end of file"); - break; - } - if (IMMED_TOKEN ()) - { - cur_token--; - if (cur_token->type == CPP_NAME) - goto continue_name; - else if (cur_token->type == CPP_NUMBER) - goto continue_number; - cur_token++; - } - /* Remember whitespace setting. */ - flags = cur_token->flags; - break; - } - else + /* backslash space newline is still treated as backslash-newline; + we think this is standard conforming, with some reservations + about actually _using_ the weasel words in C99 5.1.1.2 + (translation phase 1 is allowed to do whatever it wants to + your input as long as it's documented). */ + if (! IMMED_TOKEN ()) { buffer->cur = cur; cpp_warning (pfile, "backslash and newline separated by space"); } + + /* Remove the escaped newline. Then continue to process + any interrupted name or number. */ + cur_token--; + /* Backslash-newline may not be immediately followed by + EOF (C99 5.1.1.2). */ + if (cur >= buffer->rlimit) + { + cpp_pedwarn (pfile, "backslash-newline at end of file"); + break; + } + if (IMMED_TOKEN ()) + { + cur_token--; + if (cur_token->type == CPP_NAME) + goto continue_name; + else if (cur_token->type == CPP_NUMBER) + goto continue_number; + cur_token++; + } + /* Remember whitespace setting. */ + flags = cur_token->flags; + break; } else if (MIGHT_BE_DIRECTIVE ()) { @@ -3187,12 +3201,6 @@ _cpp_get_token (pfile) if (is_macro_disabled (pfile, node->value.expansion, token)) return token; - if (pfile->cur_context > CPP_STACK_MAX) - { - cpp_error (pfile, "macros nested too deep invoking '%s'", node->name); - return token; - } - if (push_macro_context (pfile, token)) return token; /* else loop */ |