]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Add tests for P2621, no UB in lexer [PR110340]
authorMarek Polacek <polacek@redhat.com>
Tue, 18 Jul 2023 17:26:39 +0000 (13:26 -0400)
committerMarek Polacek <polacek@redhat.com>
Tue, 18 Jul 2023 17:32:13 +0000 (13:32 -0400)
C++26 P2621 removes UB in the lexer and either makes the construct valid
or ill-formed.  We're already handling this correctly so this patch only
adds tests.

PR c++/110340

gcc/testsuite/ChangeLog:

* g++.dg/cpp/string-4.C: New test.
* g++.dg/cpp/ucn-2.C: New test.

gcc/testsuite/g++.dg/cpp/string-4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp/ucn-2.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/cpp/string-4.C b/gcc/testsuite/g++.dg/cpp/string-4.C
new file mode 100644 (file)
index 0000000..37d0388
--- /dev/null
@@ -0,0 +1,6 @@
+// P2621R2 - UB? In My Lexer?
+// { dg-do compile }
+
+// [lex.phases] If a U+0027 APOSTROPHE or a U+0022 QUOTATION
+// MARK matches the last category, the program is ill-formed.
+const char * foo=" // { dg-error "terminating|expected" }
diff --git a/gcc/testsuite/g++.dg/cpp/ucn-2.C b/gcc/testsuite/g++.dg/cpp/ucn-2.C
new file mode 100644 (file)
index 0000000..c5583e0
--- /dev/null
@@ -0,0 +1,15 @@
+// P2621R2 - UB? In My Lexer?
+// { dg-do compile }
+
+// Line splicing can form a universal-character-name [lex.charset].
+int \\
+u\
+0\
+3\
+9\
+1 = 0;
+
+// [cpp.concat] Concatenation can form a universal-character-name.
+#define CONCAT(x,y) x##y
+
+int CONCAT(\,u0393)=0;