public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-2626] c++: Add tests for P2621, no UB in lexer [PR110340]
@ 2023-07-18 17:33 Marek Polacek
  0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2023-07-18 17:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:fca089e8a47314a40ad93527ba9f9d0d374b3afb

commit r14-2626-gfca089e8a47314a40ad93527ba9f9d0d374b3afb
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Jul 18 13:26:39 2023 -0400

    c++: Add tests for P2621, no UB in lexer [PR110340]
    
    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.

Diff:
---
 gcc/testsuite/g++.dg/cpp/string-4.C |  6 ++++++
 gcc/testsuite/g++.dg/cpp/ucn-2.C    | 15 +++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/gcc/testsuite/g++.dg/cpp/string-4.C b/gcc/testsuite/g++.dg/cpp/string-4.C
new file mode 100644
index 00000000000..37d0388413c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/string-4.C
@@ -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
index 00000000000..c5583e06dd6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/ucn-2.C
@@ -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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-18 17:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-18 17:33 [gcc r14-2626] c++: Add tests for P2621, no UB in lexer [PR110340] Marek Polacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).