From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 097A33955887 for ; Wed, 22 Apr 2020 21:59:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 097A33955887 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-QF_jc_RAPMy2TMseWgxKQQ-1; Wed, 22 Apr 2020 17:59:18 -0400 X-MC-Unique: QF_jc_RAPMy2TMseWgxKQQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 813D7800FF0; Wed, 22 Apr 2020 21:59:17 +0000 (UTC) Received: from localhost (unknown [10.33.36.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CC481001B30; Wed, 22 Apr 2020 21:59:17 +0000 (UTC) Date: Wed, 22 Apr 2020 22:59:16 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed 7/8] libstdc++: Update (and revert) value of __cpp_lib_array_constexpr Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Spam-Status: No, score=-29.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Wed, 22 Apr 2020 21:59:24 -0000 This macro should have been updated to 201811 when the last C++20 changes were implemented. However those changes are not enabled for C++17 mode, so the macro should only have the new value in C++20 mode. This change ensures that the macro is defined to 201603 for C++17 and 201811 for C++20. =09* include/bits/stl_iterator.h (__cpp_lib_array_constexpr): Define =09different values for C++17 and C++20, to indicate different feature =09sets. Update value for C++20 to indicate P1032R1 support. =09* include/std/version (__cpp_lib_array_constexpr): Likewise. =09* testsuite/23_containers/array/comparison_operators/constexpr.cc: =09Check feature test macro. =09* testsuite/23_containers/array/element_access/constexpr_c++17.cc: =09New test. =09* testsuite/23_containers/array/requirements/constexpr_fill.cc: Check =09feature test macro. =09* testsuite/23_containers/array/requirements/constexpr_iter.cc: Test =09in C++17 mode and check feature test macro. --- libstdc++-v3/ChangeLog | 13 +++++ libstdc++-v3/include/bits/stl_iterator.h | 6 +- libstdc++-v3/include/std/version | 4 +- .../array/comparison_operators/constexpr.cc | 6 ++ .../array/element_access/constexpr_c++17.cc | 57 +++++++++++++++++++ .../array/requirements/constexpr_fill.cc | 6 ++ .../array/requirements/constexpr_iter.cc | 12 +++- 7 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 libstdc++-v3/testsuite/23_containers/array/element_acce= ss/constexpr_c++17.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4fec7b21029..cce254968fb 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,18 @@ 2020-04-22 Jonathan Wakely =20 +=09* include/bits/stl_iterator.h (__cpp_lib_array_constexpr): Define +=09different values for C++17 and C++20, to indicate different feature +=09sets. Update value for C++20 to indicate P1032R1 support. +=09* include/std/version (__cpp_lib_array_constexpr): Likewise. +=09* testsuite/23_containers/array/comparison_operators/constexpr.cc: +=09Check feature test macro. +=09* testsuite/23_containers/array/element_access/constexpr_c++17.cc: +=09New test. +=09* testsuite/23_containers/array/requirements/constexpr_fill.cc: Check +=09feature test macro. +=09* testsuite/23_containers/array/requirements/constexpr_iter.cc: Test +=09in C++17 mode and check feature test macro. + =09* include/std/utility (__cpp_lib_constexpr_algorithms): Do not define =09here. =09* testsuite/20_util/exchange/constexpr.cc: Do not expect macro to be diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/includ= e/bits/stl_iterator.h index 652f51c6e7f..d7e85b84041 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -69,8 +69,10 @@ # include #endif =20 -#if __cplusplus > 201402L -# define __cpp_lib_array_constexpr 201803 +#if __cplusplus > 201703L +# define __cpp_lib_array_constexpr 201811L +#elif __cplusplus =3D=3D 201703L +# define __cpp_lib_array_constexpr 201603L #endif =20 #if __cplusplus > 201703L diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/ve= rsion index 85bc142bc38..57a05259d98 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -120,7 +120,7 @@ #if _GLIBCXX_HOSTED #define __cpp_lib_any 201606L #define __cpp_lib_apply 201603 -#define __cpp_lib_array_constexpr 201803 +#define __cpp_lib_array_constexpr 201603L #define __cpp_lib_as_const 201510 #define __cpp_lib_boyer_moore_searcher 201603 #define __cpp_lib_chrono 201611 @@ -184,6 +184,8 @@ #define __cpp_lib_unwrap_ref 201811L =20 #if _GLIBCXX_HOSTED +#undef __cpp_lib_array_constexpr +#define __cpp_lib_array_constexpr 201811L #define __cpp_lib_assume_aligned 201811L #define __cpp_lib_bind_front 201907L #define __cpp_lib_integer_comparison_functions 202002L diff --git a/libstdc++-v3/testsuite/23_containers/array/comparison_operator= s/constexpr.cc b/libstdc++-v3/testsuite/23_containers/array/comparison_oper= ators/constexpr.cc index fd6029b159e..0f3a4159dea 100644 --- a/libstdc++-v3/testsuite/23_containers/array/comparison_operators/const= expr.cc +++ b/libstdc++-v3/testsuite/23_containers/array/comparison_operators/const= expr.cc @@ -20,6 +20,12 @@ =20 #include =20 +#ifndef __cpp_lib_array_constexpr +# error "Feature test macro for array constexpr is missing in " +#elif __cpp_lib_array_constexpr < 201806L +# error "Feature test macro for array constexpr has wrong value in = " +#endif + constexpr std::array a1{{1, 2, 3}}; constexpr std::array a2{{4, 5, 6}}; constexpr std::array a3{{1, 2, 4}}; diff --git a/libstdc++-v3/testsuite/23_containers/array/element_access/cons= texpr_c++17.cc b/libstdc++-v3/testsuite/23_containers/array/element_access/= constexpr_c++17.cc new file mode 100644 index 00000000000..56d1cf256be --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/array/element_access/constexpr_c= ++17.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=3Dgnu++17" } +// { dg-do compile { target c++17 } } + +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +#ifndef __cpp_lib_array_constexpr +# error "Feature test macro for array constexpr is missing in " +#elif __cpp_lib_array_constexpr < 201603L +# error "Feature test macro for array constexpr has wrong value in = " +#elif __cpp_lib_array_constexpr > 201603L && __cplusplus =3D=3D 201703 +# error "Feature test macro for array constexpr has wrong value for C++17" +#endif + +constexpr std::size_t test01() +{ + // array + typedef std::array array_type; + array_type a =3D { { 0, 55, 66, 99, 4115, 2 } }; + auto v1 =3D a[1]; + auto v2 =3D a.at(2); + auto v3 =3D a.front(); + auto v4 =3D a.back(); + return v1 + v2 + v3 + v4; +} + +static_assert( test01() =3D=3D (55 + 66 + 0 + 2) ); + +constexpr std::size_t test02() +{ + // array + typedef std::array array_type; + const array_type a =3D { { 0, 55, 66, 99, 4115, 2 } }; + auto v1 =3D a[1]; + auto v2 =3D a.at(2); + auto v3 =3D a.front(); + auto v4 =3D a.back(); + return v1 + v2 + v3 + v4; +} + +static_assert( test02() =3D=3D (55 + 66 + 0 + 2) ); diff --git a/libstdc++-v3/testsuite/23_containers/array/requirements/conste= xpr_fill.cc b/libstdc++-v3/testsuite/23_containers/array/requirements/const= expr_fill.cc index c7f9dd7b7b5..bb696346537 100644 --- a/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_fil= l.cc +++ b/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_fil= l.cc @@ -20,6 +20,12 @@ =20 #include =20 +#ifndef __cpp_lib_array_constexpr +# error "Feature test macro for array constexpr is missing in " +#elif __cpp_lib_array_constexpr < 201811L +# error "Feature test macro for array constexpr has wrong value in = " +#endif + constexpr bool test_array() { diff --git a/libstdc++-v3/testsuite/23_containers/array/requirements/conste= xpr_iter.cc b/libstdc++-v3/testsuite/23_containers/array/requirements/const= expr_iter.cc index f3f9ae6ea41..a119937f773 100644 --- a/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_ite= r.cc +++ b/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_ite= r.cc @@ -1,5 +1,5 @@ -// { dg-options "-std=3Dgnu++2a" } -// { dg-do compile { target c++2a } } +// { dg-options "-std=3Dgnu++17" } +// { dg-do compile { target c++17 } } // // Copyright (C) 2019-2020 Free Software Foundation, Inc. // @@ -20,6 +20,14 @@ =20 #include =20 +#ifndef __cpp_lib_array_constexpr +# error "Feature test macro for array constexpr is missing in " +#elif __cpp_lib_array_constexpr < 201603L +# error "Feature test macro for array constexpr has wrong value in = " +#elif __cpp_lib_array_constexpr > 201603L && __cplusplus =3D=3D 201703 +# error "Feature test macro for array constexpr has wrong value for C++17" +#endif + constexpr int test() { --=20 2.25.3