@@ -120,7 +120,7 @@ check_output_buffer (cpp_reader *pfile,
/* 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
+static bool
skip_macro_block_comment (cpp_reader *pfile)
{
const uchar *cur = pfile->buffer->cur;
@@ -131,10 +131,15 @@ skip_macro_block_comment (cpp_reader *pf
/* 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
@@ -158,7 +163,7 @@ copy_comment (cpp_reader *pfile, const u
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);
@@ -0,0 +1,8 @@
+/* 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 } */