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 128143858024 for ; Fri, 26 Nov 2021 12:40:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 128143858024 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-415-vLQQvA6cNCm5hdqFsPklsA-1; Fri, 26 Nov 2021 07:40:01 -0500 X-MC-Unique: vLQQvA6cNCm5hdqFsPklsA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 92FC783DD20; Fri, 26 Nov 2021 12:40:00 +0000 (UTC) Received: from localhost (unknown [10.33.36.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4454D1972E; Fri, 26 Nov 2021 12:40:00 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Move std::to_address tests to more appropriate place Date: Fri, 26 Nov 2021 12:39:59 +0000 Message-Id: <20211126123959.1662037-1-jwakely@redhat.com> In-Reply-To: <20211125231243.1503399-1-jwakely@redhat.com> References: <20211125231243.1503399-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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=-14.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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable 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: Fri, 26 Nov 2021 12:40:06 -0000 Tested x86_64-linux, pushed to trunk. Some of the checks in 20_util/pointer_traits/lwg3545.cc really belong in 20_util/to_address/lwg3545 instead. This also fixes the ordering of the dg-options and dg-do directives. libstdc++-v3/ChangeLog: * testsuite/20_util/pointer_traits/lwg3545.cc: Move to_address tests to ... * testsuite/20_util/to_address/lwg3545.cc: ... here. Add -std option before checking effective target. --- .../20_util/pointer_traits/lwg3545.cc | 19 ------------- .../testsuite/20_util/to_address/lwg3545.cc | 27 ++++++++++++++++++- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/libstdc++-v3/testsuite/20_util/pointer_traits/lwg3545.cc b/libstdc++-v3/testsuite/20_util/pointer_traits/lwg3545.cc index 8325cb66d08..08c3ed01b75 100644 --- a/libstdc++-v3/testsuite/20_util/pointer_traits/lwg3545.cc +++ b/libstdc++-v3/testsuite/20_util/pointer_traits/lwg3545.cc @@ -99,22 +99,3 @@ static_assert( is_same, clever_ptr>::value, "" ); static_assert( is_same, std::ptrdiff_t>::value, "" ); static_assert( is_same, clever_ptr>::value, "" ); static_assert( is_same, clever_ptr>::value, "" ); - -#if __cplusplus >= 202002L -static_assert( std::to_address(clever_ptr{}) == &clever_ptr::obj, "" ); - -int the_int; - -template<> -struct std::pointer_traits> -{ - using element_type = int; - using difference_type = std::ptrdiff_t; - using pointer = clever_ptr; - - static constexpr int* to_address(pointer p) { return &the_int; } -}; - -// Should use pointer_traits>::to_address -static_assert( std::to_address(clever_ptr{}) == &the_int, "" ); -#endif diff --git a/libstdc++-v3/testsuite/20_util/to_address/lwg3545.cc b/libstdc++-v3/testsuite/20_util/to_address/lwg3545.cc index 4dc5fdcdde0..a80ac29b2c9 100644 --- a/libstdc++-v3/testsuite/20_util/to_address/lwg3545.cc +++ b/libstdc++-v3/testsuite/20_util/to_address/lwg3545.cc @@ -1,5 +1,5 @@ -// { dg-do compile { target c++20 } } // { dg-options "-std=gnu++20" } +// { dg-do compile { target c++20 } } #include @@ -10,3 +10,28 @@ template struct nttp_ptr // This gives an error in C++20, which the LWG 3545 resolution should fix: auto x = std::to_address( nttp_ptr() ); + +template +struct clever_ptr +{ + static T obj; + constexpr T* operator->() const { return &obj; } +}; + +// pointer_traits specialization is valid, but to_address uses operator-> +static_assert( std::to_address(clever_ptr{}) == &clever_ptr::obj ); + +int the_int; + +template<> +struct std::pointer_traits> +{ + using element_type = int; + using difference_type = std::ptrdiff_t; + using pointer = clever_ptr; + + static constexpr int* to_address(pointer p) { return &the_int; } +}; + +// Uses pointer_traits>::to_address +static_assert( std::to_address(clever_ptr{}) == &the_int ); -- 2.31.1