diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-18 08:23:20 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-18 08:23:20 +0000 |
commit | ca52ef607be049bd775a725f6d77eaf554bfb2b0 (patch) | |
tree | 8d676f8eb309246fd73a05fd979264ce2b405f0e /gcc/cpptrad.c | |
parent | 02bfdd71cd1ebcfa2eb39072ecd7e8b7aefae2e4 (diff) | |
download | gcc-ca52ef607be049bd775a725f6d77eaf554bfb2b0.tar.gz |
* cppinit.c (cpp_post_options): If preprocessed, turn off
traditional. If traditional, turn off column numbers.
* cpplib.c (cpp_push_buffer): Lex from stage 3 if traditional.
* cpptrad.c (handle_newline): Update line_base.
(skip_comment): Handle -Wcomment.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53582 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpptrad.c')
-rw-r--r-- | gcc/cpptrad.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/gcc/cpptrad.c b/gcc/cpptrad.c index a6178e326d6..d5c2126a55a 100644 --- a/gcc/cpptrad.c +++ b/gcc/cpptrad.c @@ -21,9 +21,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "cpplib.h" #include "cpphash.h" -/* Lexing TODO: Handle -Wcomment, -C, maybe -CC, and space in escaped - newlines. Stop cpplex.c from recognizing comments, trigraphs and - directives during its lexing pass. */ +/* Lexing TODO: Handle -C, maybe -CC, and space in escaped newlines. + Stop cpplex.c from recognizing comments and directives during its + lexing pass. */ static const uchar *handle_newline PARAMS ((cpp_reader *, const uchar *)); static const uchar *skip_escaped_newlines PARAMS ((cpp_reader *, @@ -64,6 +64,7 @@ handle_newline (pfile, cur) pfile->line++; if (cur[0] + cur[1] == '\r' + '\n') cur++; + pfile->buffer->line_base = cur + 1; return cur + 1; } @@ -89,30 +90,31 @@ skip_comment (pfile, cur) const uchar *cur; { unsigned int from_line = pfile->line; + unsigned int c = 0, prevc; + const uchar *limit = pfile->buffer->rlimit; - for (;;) + while (cur < limit) { - unsigned int c = *cur++; - if (c == '*') + prevc = c; + c = *cur++; + + if (c == '/') { - cur = skip_escaped_newlines (pfile, cur); - if (*cur == '/') - { - cur++; - break; - } + if (prevc == '*') + break; + if (*cur == '*' && cur[1] != '/' + && CPP_OPTION (pfile, warn_comments)) + cpp_error_with_line (pfile, DL_WARNING, pfile->line, 0, + "\"/*\" within comment"); } else if (is_vspace (c)) cur = handle_newline (pfile, cur - 1); - else if (c == '\0' && cur - 1 == pfile->buffer->rlimit) - { - cur--; - cpp_error_with_line (pfile, DL_ERROR, from_line, 0, - "unterminated comment"); - break; - } } + if (c != '/' || prevc != '*') + cpp_error_with_line (pfile, DL_ERROR, from_line, 0, + "unterminated comment"); + return cur; } |