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.129.124]) by sourceware.org (Postfix) with ESMTPS id 7A13B3858414 for ; Mon, 14 Feb 2022 13:06:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7A13B3858414 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-463-83vHTqKnMF67aJIFnE46Wg-1; Mon, 14 Feb 2022 08:06:49 -0500 X-MC-Unique: 83vHTqKnMF67aJIFnE46Wg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCCA61091DA2; Mon, 14 Feb 2022 13:06:48 +0000 (UTC) Received: from localhost (unknown [10.33.36.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 725367CAD5; Mon, 14 Feb 2022 13:06:48 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use __cpp_concepts instead of custom macro [PR103891] Date: Mon, 14 Feb 2022 13:06:47 +0000 Message-Id: <20220214130647.3620885-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-13.5 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_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Feb 2022 13:06:55 -0000 Tested x86_64-linux (and clang-12.0.1), pushed to trunk. -- >8 -- With the new value of __cpp_concepts required by P2493, we can test whether the compiler supports conditionally trivial special members. This allows us to remove the workaround that disables fully-constexpr std::variant for Clang. Now it should work for non-GCC compilers (such as future releases of Clang) that support conditionally trivial destructors and define the new value of __cpp_concepts. libstdc++-v3/ChangeLog: PR libstdc++/103891 * include/bits/c++config (_GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS): Remove. * include/std/variant: Check feature test macros instead. * include/std/version: Likewise. --- libstdc++-v3/include/bits/c++config | 5 ----- libstdc++-v3/include/std/variant | 18 ++++++++---------- libstdc++-v3/include/std/version | 4 ++-- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index b197349f976..c64b61b3c90 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -810,11 +810,6 @@ namespace std #undef _GLIBCXX_HAS_BUILTIN -#if __cplusplus >= 202002L && __cpp_concepts && __GNUC__ >= 12 -// XXX workaround for missing feature test macro for P0848R3 (see P2493R0). -# define _GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS 1 -#endif - // PSTL configuration #if __cplusplus >= 201703L diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index c41f9f27e00..beed396fccb 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -44,24 +44,22 @@ #include #include #include // in_place_index_t -#ifndef _GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS -# include -#endif #if __cplusplus >= 202002L # include #endif +#if __cpp_concepts >= 202002L && __cpp_constexpr >= 201811L +// P2231R1 constexpr needs constexpr unions and constrained destructors. +# define __cpp_lib_variant 202106L +#else +# include // Use __aligned_membuf instead of union. +# define __cpp_lib_variant 202102L +#endif + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION -#ifdef _GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS -// P2231R1 constexpr needs constexpr unions and constrained destructors. -# define __cpp_lib_variant 202106L -#else -# define __cpp_lib_variant 202102L -#endif - template class tuple; template class variant; template struct hash; diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index 30e04b55555..24311ee05c8 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -175,7 +175,7 @@ # define __cpp_lib_to_chars 201611L #endif #define __cpp_lib_unordered_map_try_emplace 201411L -#ifndef _GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS +#if !(__cplusplus >= 202002L && __cpp_concepts >= 202002L) // N.B. updated value in C++20 # define __cpp_lib_variant 202102L #endif @@ -292,7 +292,7 @@ # endif #define __cpp_lib_to_address 201711L #define __cpp_lib_to_array 201907L -#ifdef _GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS +#if __cplusplus >= 202002L && __cpp_concepts >= 202002L # define __cpp_lib_variant 202106L #endif #endif -- 2.34.1