summaryrefslogtreecommitdiff
path: root/gcc/cpptrad.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.co.uk>2003-06-28 15:16:10 +0000
committerNeil Booth <neil@gcc.gnu.org>2003-06-28 15:16:10 +0000
commitdebdeb5d7073803b2acc0f92a0c8b09d1cfde5e5 (patch)
tree865b5c96c7a5b72938a905333dc8662dc0b7937e /gcc/cpptrad.c
parent735e8085f774cbd2f596077d08c08c3b24148098 (diff)
downloadgcc-debdeb5d7073803b2acc0f92a0c8b09d1cfde5e5.tar.gz
cpptrad.c (skip_macro_block_comment): New.
* cpptrad.c (skip_macro_block_comment): New. (copy_comment): Use it if appropriate. From-SVN: r68641
Diffstat (limited to 'gcc/cpptrad.c')
-rw-r--r--gcc/cpptrad.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/gcc/cpptrad.c b/gcc/cpptrad.c
index 0e4b2314bb4..9b08e31138f 100644
--- a/gcc/cpptrad.c
+++ b/gcc/cpptrad.c
@@ -116,6 +116,25 @@ check_output_buffer (cpp_reader *pfile, size_t n)
}
}
+/* Skip a C-style block comment in a macro as a result of -CC.
+ Buffer->cur points to the initial asterisk of the comment. */
+static void
+skip_macro_block_comment (cpp_reader *pfile)
+{
+ const uchar *cur = pfile->buffer->cur;
+
+ cur++;
+ if (*cur == '/')
+ cur++;
+
+ /* People like decorating comments with '*', so check for '/'
+ instead for efficiency. */
+ while(! (*cur++ == '/' && cur[-2] == '*') )
+ ;
+
+ pfile->buffer->cur = cur;
+}
+
/* CUR points to the asterisk introducing a comment in the current
context. IN_DEFINE is true if we are in the replacement text of a
macro.
@@ -136,7 +155,11 @@ copy_comment (cpp_reader *pfile, const uchar *cur, int in_define)
cpp_buffer *buffer = pfile->buffer;
buffer->cur = cur;
- unterminated = _cpp_skip_block_comment (pfile);
+ if (pfile->context->prev)
+ unterminated = false, skip_macro_block_comment (pfile);
+ else
+ unterminated = _cpp_skip_block_comment (pfile);
+
if (unterminated)
cpp_error_with_line (pfile, DL_ERROR, from_line, 0,
"unterminated comment");