From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 08CDF3882AF4 for ; Tue, 2 Apr 2024 20:13:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 08CDF3882AF4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 08CDF3882AF4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712088793; cv=none; b=lOSvmSna+JCLPtKv9wr3YqLzzhLfyHGT9cGhQELYZvyQUdqhSOfkLnH24Gdo0dfW4HlBa/m+ZuBM/z4l7QYH1RmSEqCIIzrj+aZbtu/t3Z3MBzisxalo/7gP5txKpInKnFRuVJ6mQ+F7d2GGc6UeizA9kMrL/zpQgtoAzm94rvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712088793; c=relaxed/simple; bh=MDkWH0Lmge3Re7S7O0/NSC5PqTzppVNhzmSZCtlmm4U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=IasXqMDWA+81Fv8fCr/Arg0KBfUGZdPXAchQPQOUBYljF3cngK7WErQwEjyoAhKi7IoJDGkZSmrNnW4+rrdHOTBgGrGNHlBPd+g1yC2qcZyfH2Z71KZkNfcKXI6ccu1ci8bxNTVtymSY0Fv6K5+hb4OIYynNAHRvYv9zLdtY+aA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712088791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iSMbjlSdjR1u1XYSJKjyU9Joso3Tot6jWj/6ZpA+Nls=; b=O+remOs96TM3fLq2yfL0GYcqwQC02nx28yoXonZRZLO3yBw5CUa+ku3u/SySBgEt4lo8qm tyyjEYP2tPdAA1cW1MN8JxK9ai7obDJTVGTXMsiCz2WQ1NpgCSqiYd1VfRc3AOEeds448w 7ko++nH8nV5tq/MVRGl/nc4ILPKISUY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-524-iWmW1tCiP3SlKrdC3nKE2g-1; Tue, 02 Apr 2024 16:13:10 -0400 X-MC-Unique: iWmW1tCiP3SlKrdC3nKE2g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3698F1E441CE; Tue, 2 Apr 2024 20:13:10 +0000 (UTC) Received: from localhost (unknown [10.42.28.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 077672166B32; Tue, 2 Apr 2024 20:13:09 +0000 (UTC) From: Jonathan Wakely 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 Message-ID: <20240402201305.142254-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,URI_HEX autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 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 -- 2.44.0