]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libcpp: Fix up handling of block comments in -fdirectives-only mode [PR103130]
authorJakub Jelinek <jakub@redhat.com>
Wed, 17 Nov 2021 16:31:40 +0000 (17:31 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 17 Nov 2021 16:31:40 +0000 (17:31 +0100)
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.

2021-11-17  Jakub Jelinek  <jakub@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.

gcc/testsuite/c-c++-common/cpp/dir-only-9.c [new file with mode: 0644]
libcpp/lex.c

diff --git a/gcc/testsuite/c-c++-common/cpp/dir-only-9.c b/gcc/testsuite/c-c++-common/cpp/dir-only-9.c
new file mode 100644 (file)
index 0000000..d11cd97
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR preprocessor/103130 */
+/* { dg-do preprocess } */
+/* { dg-options -fdirectives-only } */
+
+/*\
+ * this is a comment
+\*/
+
+int
+main ()
+{
+  return 0;
+}
index 6a4fbce6030c00ce84c8c9ac9eb7ed9bcac87324..8188e33b07d3dfef97d085722d24d03947f94caa 100644 (file)
@@ -4891,7 +4891,7 @@ cpp_directive_only_process (cpp_reader *pfile,
                        break;
 
                      case '*':
-                       if (pos > peek && !esc)
+                       if (pos > peek)
                          star = is_block;
                        esc = false;
                        break;