From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id B15543861806; Tue, 2 Apr 2024 20:12:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B15543861806 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712088769; bh=zuymkm21vv/LCpexwrDFbv7kcbDh2UcwaaS6N50yTX8=; h=From:To:Subject:Date:From; b=P7lQpZVZ+4KYP8ceoSJmbhdKocKp446y9C3o4iqG9msY9KUjzC+PyX/i8utU2p8u8 eAzjDe+7WZ/jqin9NcXZIGtThF3VyiEzn8YTeLDFaUw0FXwJhkFFLVT6FDF/p+zOy3 WIndwSLd/uteG4MdU3kjTuoPC/4r3yHq98Tv9J0o= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-9761] libstdc++: Guard uses of char8_t with __cpp_char8_t [PR114519] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: ca2f7c84927f85b95f0f48f82b93f1460c372db4 X-Git-Newrev: 21aa57e73b820395b7b01843d61ef5b84cd20d02 Message-Id: <20240402201249.B15543861806@sourceware.org> Date: Tue, 2 Apr 2024 20:12:49 +0000 (GMT) List-Id: https://gcc.gnu.org/g:21aa57e73b820395b7b01843d61ef5b84cd20d02 commit r14-9761-g21aa57e73b820395b7b01843d61ef5b84cd20d02 Author: Jonathan Wakely Date: Thu Mar 28 21:29:17 2024 +0000 libstdc++: Guard uses of char8_t with __cpp_char8_t [PR114519] 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. Diff: --- libstdc++-v3/include/bits/unicode.h | 10 +++++++--- libstdc++-v3/testsuite/std/format/functions/114519.cc | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) 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 using _Utf8_view = _Utf_view; +#endif template using _Utf16_view = _Utf_view; template @@ -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