From patchwork Fri Jan 5 10:23:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 185355 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6158898dyb; Fri, 5 Jan 2024 03:29:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUTLLuScSMoCpJouV16kxwJnXkMklKAADxIsN/cS/a/vf7IAiltPLqr2tAhCsbLepBsddo X-Received: by 2002:a5b:90e:0:b0:dbd:6017:84df with SMTP id a14-20020a5b090e000000b00dbd601784dfmr1487541ybq.10.1704454188350; Fri, 05 Jan 2024 03:29:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704454188; cv=pass; d=google.com; s=arc-20160816; b=P3WCPEaK2O/BbSvc9zYxwEXpjGPKYAdHp6U6H5ZC3vVh1F170umSrGrYGn8XyRAPL+ quazmBV7Ea8QEKZKEVOeCaLXmNfMz4iszAIgSP8me4ApON7GjOWP0i2dNOJ9ckPgdtwA YRIwBCOIUt/+7rrsR23+RwlmcWiOkaj9Kjlx4m7UlfX34lmxPt15O1DVoyWqHIbymva7 Di5/hdEuIuz1KOc8OMmulYFsvWJtuoa6fCW2GfWAsNAcqRsSD0zlQIpA7DzEeYgD9lLF EOPeOkLJvun1SH1vwj8G4s0B+t9dVooUDLT/Y2UPXVs/lVEh3Ud4T/t58zcMsMducmsP PU2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=FUjYs+Mb0rc3SsQpm3cS0ge1fvQRPcMWsIdTTpRNkJI=; fh=sJ+2/4g29YdyXkoRrFZSpsL2zxijepB7X/1rB0LDDh8=; b=VBukbjMeoBeq/7RfEYssCpOSWqDMnNQVtlzsqGEGqhgbHe546J69YBmTj/MeQp5AGj 1AkuTfGpA9baFmRP9sbweLOFH21FQnqGMhE4H8144HOVHxplVdwXJ/HXTiCrf3kpnciu u87IFUIAd6WIj9rwUHSWen0AYh0ZTFLoSjMt1wdH8iiS3c7A8YPaZRde/sDxRmlRaaaI R9hQ3YshRki33bPa4bzSV3tKtJ9ODmx3mmRpFv89fXJ9KDNXt/8jfyf4pnYf/w7L6/WC KzsSvHQV1zX6v5+WS58uqcMcywc014neMnCu+gdqVO36OQa0etgTxT68QVfBLQfZ7uEG +KsQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E9Desb36; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id s11-20020a05622a178b00b00423a0dfaae7si1598570qtk.707.2024.01.05.03.29.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 03:29:48 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E9Desb36; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 88636385E82E for ; Fri, 5 Jan 2024 10:26:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 748043858D32 for ; Fri, 5 Jan 2024 10:24:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 748043858D32 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 748043858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704450281; cv=none; b=XpoJQND0LRoX5TXR3kaEiYYahttgFUuw6uT77lvyCCXQQsVieLs0rt2boig8dY+/2Pf5nPO11beEJgb85C/IMPt7RHAdV4V9qVaWvZVtZBnPmvYHm2Dl1yfQnG6dSMbyWHSDAgJSfc2HUePF2c9gfpNknjoqZkV9x6o+xM98TIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704450281; c=relaxed/simple; bh=pTjF2y9vOErQ5/Ui6+YFmsJXIcE+8cV2edUfKmi3TZM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=fTzHgS2zybYCqlmfQFNri5xuaJ1Mv8n33W1fJXmPM1wmqbqm4jWNls3EcLnNaMle4MnEgDIw3h0hXE10606wB7aUpljNVJVKNDl+lCy4w1XfFOWy7zrOQLLbPzOy5kf+LLyuZMQ4DkjtGsDW+IijIkZu1jnRWFWkTVPG0rPMMmg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704450277; 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=FUjYs+Mb0rc3SsQpm3cS0ge1fvQRPcMWsIdTTpRNkJI=; b=E9Desb36wt2juXxsM8ALcCvzx5dU+Yn7S2IfMac7QuzWQAW+4uIwy19KHmdxchrhiGs1Fr 912KW7X2ZzB5gU/AZmvnPMeXxtpRmmEg65S+mk8KWwE4YQL3fdjUTwTrUbTQpZW5lD5u+u Kvk0Nip3NhTcfHHEUZED7JqN6tPK6/s= 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-167-kBZBPCLnOaSa5V1seQ4CFg-1; Fri, 05 Jan 2024 05:24:34 -0500 X-MC-Unique: kBZBPCLnOaSa5V1seQ4CFg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 3C17F28040B4; Fri, 5 Jan 2024 10:24:33 +0000 (UTC) Received: from localhost (unknown [10.42.28.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 066723C25; Fri, 5 Jan 2024 10:24:32 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use if-constexpr in std::__try_use_facet [PR113099] Date: Fri, 5 Jan 2024 10:23:48 +0000 Message-ID: <20240105102432.3180887-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.4 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787249755156019996 X-GMAIL-MSGID: 1787249755156019996 Tested x86_64-linux. Pushed to trunk. -- >8 -- As noted in the PR, we can use if-constexpr for the explicit instantantiation definitions that are compiled with -std=gnu++11. We just need to disable the -Wc++17-extensions diagnostics. libstdc++-v3/ChangeLog: PR libstdc++/113099 * include/bits/locale_classes.tcc (__try_use_facet): Use if-constexpr for C++11 and up. --- libstdc++-v3/include/bits/locale_classes.tcc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/locale_classes.tcc b/libstdc++-v3/include/bits/locale_classes.tcc index 2a6176fb4de..63097582dec 100644 --- a/libstdc++-v3/include/bits/locale_classes.tcc +++ b/libstdc++-v3/include/bits/locale_classes.tcc @@ -87,6 +87,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __s2.data(), __s2.data() + __s2.length()) < 0); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wc++17-extensions" template inline const _Facet* __try_use_facet(const locale& __loc) _GLIBCXX_NOTHROW @@ -97,7 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // We know these standard facets are always installed in every locale // so dynamic_cast always succeeds, just use static_cast instead. #define _GLIBCXX_STD_FACET(...) \ - if _GLIBCXX17_CONSTEXPR (__is_same(_Facet, __VA_ARGS__)) \ + if _GLIBCXX_CONSTEXPR (__is_same(_Facet, __VA_ARGS__)) \ return static_cast(__facets[__i]) _GLIBCXX_STD_FACET(ctype); @@ -145,6 +147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return static_cast(__facets[__i]); #endif } +#pragma GCC diagnostic pop /** * @brief Test for the presence of a facet.