Hi!

Normal preprocessing, -fdirectives-only preprocessing before the Nathan's
rewrite, and all other compilers I've tried on godbolt treat even \*/
as end of a block comment, but the new -fdirectives-only handling doesn't.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2021-11-17  Jakub Jelinek  <ja...@redhat.com>

        PR preprocessor/103130
        * lex.c (cpp_directive_only_process): Treat even \*/ as end of block
        comment.

        * c-c++-common/cpp/dir-only-9.c: New test.

--- libcpp/lex.c.jj     2021-11-01 14:37:06.706853026 +0100
+++ libcpp/lex.c        2021-11-16 16:54:04.022644499 +0100
@@ -4493,7 +4493,7 @@ cpp_directive_only_process (cpp_reader *
                        break;
 
                      case '*':
-                       if (pos > peek && !esc)
+                       if (pos > peek)
                          star = is_block;
                        esc = false;
                        break;
--- gcc/testsuite/c-c++-common/cpp/dir-only-9.c.jj      2021-11-16 
16:56:57.121217975 +0100
+++ gcc/testsuite/c-c++-common/cpp/dir-only-9.c 2021-11-16 16:56:14.524815094 
+0100
@@ -0,0 +1,13 @@
+/* PR preprocessor/103130 */
+/* { dg-do preprocess } */
+/* { dg-options -fdirectives-only } */
+
+/*\
+ * this is a comment
+\*/
+
+int
+main ()
+{
+  return 0;
+}

        Jakub

Reply via email to