]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Add test for vt/ff in line comments
authorJakub Jelinek <jakub@redhat.com>
Wed, 6 Aug 2025 08:44:09 +0000 (10:44 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 6 Aug 2025 08:44:09 +0000 (10:44 +0200)
P2843R3 dropped the
"If there is a form-feed or a vertical-tab character in such a comment, only
whitespace characters shall appear between it and the new-line that terminates
the comment; no diagnostic is required."
sentence from [lex.comment].  AFAIK we've never diagnosed nor checked for
that and C23 doesn't have anything like that, so the following testcase
merely tests that we don't diagnose anything on it.

2025-08-06  Jakub Jelinek  <jakub@redhat.com>

PR preprocessor/120778
* c-c++-common/cpp/comment-ff-1.c: New test.
* c-c++-common/cpp/comment-vtab-1.c: New test.

gcc/testsuite/c-c++-common/cpp/comment-ff-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/comment-vtab-1.c [new file with mode: 0644]

diff --git a/gcc/testsuite/c-c++-common/cpp/comment-ff-1.c b/gcc/testsuite/c-c++-common/cpp/comment-ff-1.c
new file mode 100644 (file)
index 0000000..0d071b1
--- /dev/null
@@ -0,0 +1,12 @@
+// C++26 P2843R3 - Preprocessing is never undefined
+// Test that form-feed followed by non-whitespace
+// in line comments are accepted.
+// { dg-do compile }
+// { dg-options "-pedantic-errors -Wall -W" }
+
+// \f
+int a;
+// \f   
+int b;
+// \f comment
+int c;
diff --git a/gcc/testsuite/c-c++-common/cpp/comment-vtab-1.c b/gcc/testsuite/c-c++-common/cpp/comment-vtab-1.c
new file mode 100644 (file)
index 0000000..03feb73
--- /dev/null
@@ -0,0 +1,12 @@
+// C++26 P2843R3 - Preprocessing is never undefined
+// Test that vertical tab followed by non-whitespace
+// in line comments are accepted.
+// { dg-do compile }
+// { dg-options "-pedantic-errors -Wall -W" }
+
+// \v
+int a;
+// \v   
+int b;
+// \v comment
+int c;