From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Guard uses of char8_t with __cpp_char8_t [PR114519]
Date: Tue, 2 Apr 2024 21:12:50 +0100 [thread overview]
Message-ID: <20240402201305.142254-1-jwakely@redhat.com> (raw)
Tested x86_64-linux. Pushed to trunk.
-- >8 --
libstdc++-v3/ChangeLog:
PR libstdc++/114519
* include/bits/unicode.h (_Utf8_view): Guard with check for
char8_t being enabled.
(__literal_encoding_is_unicode): Guard use of char8_t with check
for it being enabled.
* testsuite/std/format/functions/114519.cc: New test.
---
libstdc++-v3/include/bits/unicode.h | 10 +++++++---
libstdc++-v3/testsuite/std/format/functions/114519.cc | 3 +++
2 files changed, 10 insertions(+), 3 deletions(-)
create mode 100644 libstdc++-v3/testsuite/std/format/functions/114519.cc
diff --git a/libstdc++-v3/include/bits/unicode.h b/libstdc++-v3/include/bits/unicode.h
index 51bf02e927f..0e95c86a0b0 100644
--- a/libstdc++-v3/include/bits/unicode.h
+++ b/libstdc++-v3/include/bits/unicode.h
@@ -578,8 +578,10 @@ namespace __unicode
constexpr bool empty() const { return ranges::empty(_M_base); }
};
+#ifdef __cpp_char8_t
template<typename _View>
using _Utf8_view = _Utf_view<char8_t, _View>;
+#endif
template<typename _View>
using _Utf16_view = _Utf_view<char16_t, _View>;
template<typename _View>
@@ -991,12 +993,14 @@ inline namespace __v15_1_0
consteval bool
__literal_encoding_is_unicode()
{
- if constexpr (is_same_v<_CharT, char8_t>)
- return true;
- else if constexpr (is_same_v<_CharT, char16_t>)
+ if constexpr (is_same_v<_CharT, char16_t>)
return true;
else if constexpr (is_same_v<_CharT, char32_t>)
return true;
+#ifdef __cpp_char8_t
+ else if constexpr (is_same_v<_CharT, char8_t>)
+ return true;
+#endif
const char* __enc = "";
diff --git a/libstdc++-v3/testsuite/std/format/functions/114519.cc b/libstdc++-v3/testsuite/std/format/functions/114519.cc
new file mode 100644
index 00000000000..25a112a954e
--- /dev/null
+++ b/libstdc++-v3/testsuite/std/format/functions/114519.cc
@@ -0,0 +1,3 @@
+// { dg-do compile { target c++20 } }
+// { dg-options "-fno-char8_t" }
+#include <format>
--
2.44.0
reply other threads:[~2024-04-02 20:13 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=20240402201305.142254-1-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/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).