diff options
author | Neil Booth <neilb@earthling.net> | 2000-10-30 22:29:00 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2000-10-30 22:29:00 +0000 |
commit | a5c3cccda43ddeaa0e90df75f74c230dea0ad579 (patch) | |
tree | aea40a1085df8546a232c08b4db9f87353674441 /gcc/cpplex.c | |
parent | dbdaea4110d5c97ba1addef900516eea7846a2c0 (diff) | |
download | gcc-a5c3cccda43ddeaa0e90df75f74c230dea0ad579.zip gcc-a5c3cccda43ddeaa0e90df75f74c230dea0ad579.tar.gz gcc-a5c3cccda43ddeaa0e90df75f74c230dea0ad579.tar.bz2 |
cppfiles.c (stack_include_file): Check for stacked contexts here.
* cppfiles.c (stack_include_file): Check for stacked contexts
here.
* cpphash.h (_cpp_do__Pragma): New prototype.
* cppinit.c (cpp_reader_init): Add _Pragma keyword to hash table.
* cpplex.c (skip_escaped_newlines): Only process trigraphs and
escaped newlines if !(buffer->from_stage3).
(_cpp_lex_token): Warn about missing newlines iff
!buffer->from_stage3.
* cpplib.c (get__Pragma_string, destringize,
_cpp_do__Pragma): New functions.
(run_directive): Set output_line for _Pragma to avoid line
markers in output. Set from_stage3 and prevent macro expansion
for _Pragma and command-line options. Check buffer exhaustion.
(cpp_push_buffer): Don't check for stacked macro contexts, as
this is perfectly legitimate for _Pragma. Move the check to
stack_include_file instead. Set from_stage3 iff buffer is
preprocessed input.
* cpplib.h (struct cpp_buffer): Make warned_cplusplus_comments
unsigned. New boolean from_stage3.
(struct spec_nodes): Add n__Pragma.
* cppmacro.c (enter_macro_context): Flip sense of return value.
(_cpp_get_token): Handle _Pragma operator.
From-SVN: r37147
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r-- | gcc/cpplex.c | 104 |
1 files changed, 55 insertions, 49 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c index ac8c3c4..43e090b 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -181,71 +181,77 @@ trigraph_ok (pfile, from_char) /* Skips any escaped newlines introduced by NEXT, which is either a '?' or a '\\'. Returns the next character, which will also have - been placed in buffer->read_ahead. */ + been placed in buffer->read_ahead. This routine performs + preprocessing stages 1 and 2 of the ISO C standard. */ static cppchar_t skip_escaped_newlines (buffer, next) cpp_buffer *buffer; cppchar_t next; { - cppchar_t next1; - const unsigned char *saved_cur; - int space; - - do + /* Only do this if we apply stages 1 and 2. */ + if (!buffer->from_stage3) { - if (buffer->cur == buffer->rlimit) - break; - - SAVE_STATE (); - if (next == '?') + cppchar_t next1; + const unsigned char *saved_cur; + int space; + + do { - next1 = *buffer->cur++; - if (next1 != '?' || buffer->cur == buffer->rlimit) + if (buffer->cur == buffer->rlimit) + break; + + SAVE_STATE (); + if (next == '?') { - RESTORE_STATE (); - break; + next1 = *buffer->cur++; + if (next1 != '?' || buffer->cur == buffer->rlimit) + { + RESTORE_STATE (); + break; + } + + next1 = *buffer->cur++; + if (!_cpp_trigraph_map[next1] + || !trigraph_ok (buffer->pfile, next1)) + { + RESTORE_STATE (); + break; + } + + /* We have a full trigraph here. */ + next = _cpp_trigraph_map[next1]; + if (next != '\\' || buffer->cur == buffer->rlimit) + break; + SAVE_STATE (); + } + + /* We have a backslash, and room for at least one more character. */ + space = 0; + do + { + next1 = *buffer->cur++; + if (!is_nvspace (next1)) + break; + space = 1; } + while (buffer->cur < buffer->rlimit); - next1 = *buffer->cur++; - if (!_cpp_trigraph_map[next1] || !trigraph_ok (buffer->pfile, next1)) + if (!is_vspace (next1)) { RESTORE_STATE (); break; } - /* We have a full trigraph here. */ - next = _cpp_trigraph_map[next1]; - if (next != '\\' || buffer->cur == buffer->rlimit) - break; - SAVE_STATE (); - } + if (space) + cpp_warning (buffer->pfile, + "backslash and newline separated by space"); - /* We have a backslash, and room for at least one more character. */ - space = 0; - do - { - next1 = *buffer->cur++; - if (!is_nvspace (next1)) - break; - space = 1; - } - while (buffer->cur < buffer->rlimit); - - if (!is_vspace (next1)) - { - RESTORE_STATE (); - break; + next = handle_newline (buffer, next1); + if (next == EOF) + cpp_pedwarn (buffer->pfile, "backslash-newline at end of file"); } - - if (space) - cpp_warning (buffer->pfile, - "backslash and newline separated by space"); - - next = handle_newline (buffer, next1); - if (next == EOF) - cpp_pedwarn (buffer->pfile, "backslash-newline at end of file"); + while (next == '\\' || next == '?'); } - while (next == '\\' || next == '?'); buffer->read_ahead = next; return next; @@ -863,8 +869,8 @@ _cpp_lex_token (pfile, result) { case EOF: /* Non-empty files should end in a newline. Ignore for command - line - we get e.g. -A options with no trailing \n. */ - if (pfile->lexer_pos.col != 0 && pfile->done_initializing) + line and _Pragma buffers. */ + if (pfile->lexer_pos.col != 0 && !buffer->from_stage3) cpp_pedwarn (pfile, "no newline at end of file"); pfile->state.skip_newlines = 1; result->type = CPP_EOF; |