public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed 8/8] libstdc++: Define __cpp_lib_execution feature test macro
Date: Wed, 22 Apr 2020 22:59:24 +0100	[thread overview]
Message-ID: <aac39307e8f589dba231083a3e9aa3d0ff302837.1587592482.git.jwakely@redhat.com> (raw)
In-Reply-To: <cover.1587592482.git.jwakely@redhat.com>

This macro has never been defined by libstdc++, despite supporting the
parallel algorithms. It should have a different value for C++17 and
C++20, because P1001R2 should not be supported in C++17, but
unsequenced_policy is defined for C++17 (see PR p4702).

	* include/std/execution (__cpp_lib_execution): Define to indicate
	support for P0024R2 and P1001R2.
	* include/std/version (__cpp_lib_execution): Define.
	* testsuite/25_algorithms/pstl/feature_test.cc: Only test macro
	defined by <algorithm>, move other tests to new tests ...
	* testsuite/25_algorithms/pstl/feature_test-2.cc: New test.
	* testsuite/25_algorithms/pstl/feature_test-3.cc: New test.
	* testsuite/25_algorithms/pstl/feature_test-4.cc: New test.
	* testsuite/25_algorithms/pstl/feature_test-5.cc: New test.
---
 libstdc++-v3/ChangeLog                        | 10 ++++++
 libstdc++-v3/include/std/execution            |  1 +
 libstdc++-v3/include/std/version              |  2 ++
 .../25_algorithms/pstl/feature_test-2.cc      | 27 +++++++++++++++
 .../25_algorithms/pstl/feature_test-3.cc      | 34 +++++++++++++++++++
 .../25_algorithms/pstl/feature_test-4.cc      | 33 ++++++++++++++++++
 .../25_algorithms/pstl/feature_test-5.cc      | 28 +++++++++++++++
 .../25_algorithms/pstl/feature_test.cc        | 27 ++-------------
 8 files changed, 137 insertions(+), 25 deletions(-)
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-2.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-3.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-4.cc
 create mode 100644 libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-5.cc

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index cce254968fb..fb0c1acd268 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,15 @@
 2020-04-22  Jonathan Wakely  <jwakely@redhat.com>
 
+	* include/std/execution (__cpp_lib_execution): Define to indicate
+	support for P0024R2 and P1001R2.
+	* include/std/version (__cpp_lib_execution): Define.
+	* testsuite/25_algorithms/pstl/feature_test.cc: Only test macro
+	defined by <algorithm>, move other tests to new tests ...
+	* testsuite/25_algorithms/pstl/feature_test-2.cc: New test.
+	* testsuite/25_algorithms/pstl/feature_test-3.cc: New test.
+	* testsuite/25_algorithms/pstl/feature_test-4.cc: New test.
+	* testsuite/25_algorithms/pstl/feature_test-5.cc: New test.
+
 	* include/bits/stl_iterator.h (__cpp_lib_array_constexpr): Define
 	different values for C++17 and C++20, to indicate different feature
 	sets. Update value for C++20 to indicate P1032R1 support.
diff --git a/libstdc++-v3/include/std/execution b/libstdc++-v3/include/std/execution
index ac78af8eac3..cdd852deb14 100644
--- a/libstdc++-v3/include/std/execution
+++ b/libstdc++-v3/include/std/execution
@@ -50,6 +50,7 @@
 
 // Feature test macro for parallel algorithms
 # define __cpp_lib_parallel_algorithm 201603L
+# define __cpp_lib_execution 201902L
 
 #endif // C++17
 
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index 57a05259d98..3024f1caf8b 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -127,6 +127,7 @@
 #define __cpp_lib_clamp 201603
 #define __cpp_lib_constexpr_char_traits 201611
 #define __cpp_lib_enable_shared_from_this 201603
+#define __cpp_lib_execution 201902L // FIXME: should be 201603L
 #define __cpp_lib_filesystem 201703
 #define __cpp_lib_gcd 201606
 #define __cpp_lib_gcd_lcm 201606
@@ -188,6 +189,7 @@
 #define __cpp_lib_array_constexpr 201811L
 #define __cpp_lib_assume_aligned 201811L
 #define __cpp_lib_bind_front 201907L
+// FIXME: #define __cpp_lib_execution 201902L
 #define __cpp_lib_integer_comparison_functions 202002L
 #define __cpp_lib_constexpr_algorithms 201806L
 #define __cpp_lib_constexpr_complex 201711L
diff --git a/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-2.cc b/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-2.cc
new file mode 100644
index 00000000000..3e74f89bc41
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-2.cc
@@ -0,0 +1,27 @@
+// Copyright (C) 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do preprocess { target c++17 } }
+
+#include <numeric>
+
+#ifndef __cpp_lib_parallel_algorithm
+# error "Feature-test macro for parallel algorithms missing in <numeric>"
+#elif __cpp_lib_parallel_algorithm != 201603L
+# error "Feature-test macro for parallel algorithms has wrong value in <numeric>"
+#endif
diff --git a/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-3.cc b/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-3.cc
new file mode 100644
index 00000000000..7693fe03548
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-3.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do preprocess { target c++17 } }
+
+#include <execution>
+
+#ifndef __cpp_lib_execution
+# error "Feature-test macro for execution policies is missing in <execution>"
+#elif __cpp_lib_execution != 201902L
+# error "Feature-test macro for parallel algorithms has wrong value in <execution>"
+#endif
+
+// Neither SD-6 nor C++20 requires this macro to be defined in <execution>.
+#ifndef __cpp_lib_parallel_algorithm
+# error "Feature-test macro for parallel algorithms missing in <execution>"
+#elif __cpp_lib_parallel_algorithm != 201603L
+# error "Feature-test macro for parallel algorithms has wrong value in <execution>"
+#endif
diff --git a/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-4.cc b/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-4.cc
new file mode 100644
index 00000000000..e7bbf920499
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-4.cc
@@ -0,0 +1,33 @@
+// Copyright (C) 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do preprocess { target c++17 } }
+
+#include <version>
+
+#ifndef __cpp_lib_parallel_algorithm
+# error "Feature-test macro for parallel algorithms missing in <version>"
+#elif __cpp_lib_parallel_algorithm != 201603L
+# error "Feature-test macro for parallel algorithms has wrong value in <version>"
+#endif
+
+#ifndef __cpp_lib_execution
+# error "Feature-test macro for execution policies is missing in <version>"
+#elif __cpp_lib_execution != 201902L
+# error "Feature-test macro for parallel algorithms has wrong value in <version>"
+#endif
diff --git a/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-5.cc b/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-5.cc
new file mode 100644
index 00000000000..2d991958e75
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-5.cc
@@ -0,0 +1,28 @@
+// Copyright (C) 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do preprocess { target c++17 } }
+
+#include <memory>
+
+// Neither SD-6 nor C++20 requires this macro to be defined in <memory>.
+#ifndef __cpp_lib_parallel_algorithm
+# error "Feature-test macro for parallel algorithms missing in <memory>"
+#elif __cpp_lib_parallel_algorithm != 201603L
+# error "Feature-test macro for parallel algorithms has wrong value in <memory>"
+#endif
diff --git a/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test.cc b/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test.cc
index ce41f538c83..c3a9be5e45a 100644
--- a/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/pstl/feature_test.cc
@@ -19,32 +19,9 @@
 // { dg-do preprocess { target c++17 } }
 
 #include <algorithm>
+
 #ifndef __cpp_lib_parallel_algorithm
-# error "Feature-test macro for parallel algorithms missing"
+# error "Feature-test macro for parallel algorithms missing in <algorithm>"
 #elif __cpp_lib_parallel_algorithm != 201603L
 # error "Feature-test macro for parallel algorithms has wrong value in <algorithm>"
 #endif
-
-#include <numeric>
-#if __cpp_lib_parallel_algorithm != 201603L
-# error "Feature-test macro for parallel algorithms has wrong value in <numeric>"
-#endif
-
-#include <version>
-#if __cpp_lib_parallel_algorithm != 201603L
-# error "Feature-test macro for parallel algorithms has wrong value in <version>"
-#endif
-
-// The N4810 draft does not require the macro to be defined in <execution>.
-#include <memory>
-#if __cpp_lib_parallel_algorithm != 201603L
-# error "Feature-test macro for parallel algorithms has wrong value in <memory>"
-#endif
-
-// The N4810 draft does not require the macro to be defined in <execution>.
-// Include this last, because it will trigger the inclusion of TBB headers,
-// which then include <memory>, so we need to have already checked <memory>.
-#include <execution>
-#if __cpp_lib_parallel_algorithm != 201603L
-# error "Feature-test macro for parallel algorithms has wrong value in <execution>"
-#endif
-- 
2.25.3


  parent reply	other threads:[~2020-04-22 21:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-22 21:57 [committed 0/8] libstdc++: Add/update/fix feature test macros Jonathan Wakely
2020-04-22 21:58 ` [committed 1/8] libstdc++: Update value of __cpp_lib_jthread macro Jonathan Wakely
2020-04-22 21:58 ` [committed 2/8] libstdc++: Remove non-standard feature test macros Jonathan Wakely
2020-04-22 21:58 ` [committed 3/8] libstdc++: Add missing " Jonathan Wakely
2020-04-22 21:58 ` [committed 4/8] libstdc++: Rename __cpp_lib_constexpr_invoke macro Jonathan Wakely
2020-04-22 21:59 ` [committed 5/8] libstdc++: Update __cpp_lib_concepts value Jonathan Wakely
2020-04-22 21:59 ` [committed 6/8] libstdc++: Do not define __cpp_lib_constexpr_algorithms in <utility> Jonathan Wakely
2020-04-22 21:59 ` [committed 7/8] libstdc++: Update (and revert) value of __cpp_lib_array_constexpr Jonathan Wakely
2020-04-23 20:44   ` Jonathan Wakely
2020-04-22 21:59 ` Jonathan Wakely [this message]
2020-04-23 20:41 ` [committed 9/8] libstdc++: Define __cpp_lib_three_way_comparison for freestanding Jonathan Wakely
2020-04-23 20:46 ` [committed 0/8] libstdc++: Add/update/fix feature test macros Jonathan Wakely
2020-04-28 22:52 ` [committed 10/8] libstdc++: Fixes for feature test macros (PR 91480) Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aac39307e8f589dba231083a3e9aa3d0ff302837.1587592482.git.jwakely@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).