testsuite: Add testcase from C++23 P2314R4 - Character sets and encodings
authorJakub Jelinek <jakub@redhat.com>
Fri, 4 Nov 2022 17:20:36 +0000 (18:20 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 4 Nov 2022 17:20:36 +0000 (18:20 +0100)
I've read the paper and I believe we just implement it with no changes
needed (at least since PR67224 and similar libcpp changes in GCC 10),
but I could be wrong.

The following patch at least adds a testcase from the start of the paper.

2022-11-04  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/cpp23/charset1.C: New testcase from C++23 P2314R4.

gcc/testsuite/g++.dg/cpp23/charset1.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/cpp23/charset1.C b/gcc/testsuite/g++.dg/cpp23/charset1.C
new file mode 100644 (file)
index 0000000..d6f0d1c
--- /dev/null
@@ -0,0 +1,10 @@
+// P2314R4
+// { dg-do compile { target c++23 } }
+// { dg-options "-finput-charset=UTF-8 -fexec-charset=UTF-8" }
+
+#define S(x) # x
+const char s1[] = S(Köppe);       // "Köppe"
+const char s2[] = S(K\u00f6ppe);  // "Köppe"
+
+static_assert (sizeof (s1) == 7);
+static_assert (sizeof (s2) == 7);