--- /dev/null
+/* PR preprocessor/69869 */
+/* { dg-do preprocess } */
+/* { dg-options "-traditional-cpp" } */
+
+#define C(a,b)a/**/b
+C (foo/,**/)
+C (foo/,*)
+/* { dg-error "-:unterminated comment" "" {target "*-*-*"} .-1 } */
+2018-01-31 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/69869
+ * traditional.c (skip_macro_block_comment): Return bool, true if
+ the macro block comment is unterminated.
+ (copy_comment): Use return value from skip_macro_block_comment instead
+ of always false.
+
2018-01-27 Jakub Jelinek <jakub@redhat.com>
* include/cpplib.h (enum cpp_builtin_type): Change BT_LAST_USER from
}
/* 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
+ PFILE->buffer->cur points to the initial asterisk of the comment,
+ change it to point to after the '*' and '/' characters that terminate it.
+ Return true if the macro has not been termined, in that case set
+ PFILE->buffer->cur to the end of the buffer. */
+static bool
skip_macro_block_comment (cpp_reader *pfile)
{
const uchar *cur = pfile->buffer->cur;
/* People like decorating comments with '*', so check for '/'
instead for efficiency. */
- while(! (*cur++ == '/' && cur[-2] == '*') )
- ;
+ while (! (*cur++ == '/' && cur[-2] == '*'))
+ if (cur[-1] == '\n')
+ {
+ pfile->buffer->cur = cur - 1;
+ return true;
+ }
pfile->buffer->cur = cur;
+ return false;
}
/* CUR points to the asterisk introducing a comment in the current
buffer->cur = cur;
if (pfile->context->prev)
- unterminated = false, skip_macro_block_comment (pfile);
+ unterminated = skip_macro_block_comment (pfile);
else
unterminated = _cpp_skip_block_comment (pfile);