From: Marek Polacek <polacek@redhat.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Jason Merrill <jason@redhat.com>
Subject: [pushed] c++: Add tests for P2621, no UB in lexer [PR110340]
Date: Tue, 18 Jul 2023 13:33:14 -0400 [thread overview]
Message-ID: <20230718173314.72666-1-polacek@redhat.com> (raw)
Tested x86_64-pc-linux-gnu, applying to trunk.
-- 8< --
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 | 6 ++++++
gcc/testsuite/g++.dg/cpp/ucn-2.C | 15 +++++++++++++++
2 files changed, 21 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp/string-4.C
create mode 100644 gcc/testsuite/g++.dg/cpp/ucn-2.C
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;
base-commit: 05fc7db93452841280ddc5cdf71b33498ed576dc
--
2.41.0
reply other threads:[~2023-07-18 17:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230718173314.72666-1-polacek@redhat.com \
--to=polacek@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).