]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Define __cpp_lib_execution feature test
authorJonathan Wakely <jwakely@redhat.com>
Thu, 23 Apr 2020 17:48:50 +0000 (18:48 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 23 Apr 2020 20:12:25 +0000 (21:12 +0100)
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 94702).

Backport from mainline
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.

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/execution
libstdc++-v3/include/std/version
libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-3.cc [new file with mode: 0644]
libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/25_algorithms/pstl/feature_test-5.cc [new file with mode: 0644]
libstdc++-v3/testsuite/25_algorithms/pstl/feature_test.cc

index ff8856fc0c3cf756b61de9365b704f3d145a1b34..85d8c9e4feaa10436efec5bdb6df01c043bd81f1 100644 (file)
@@ -1,5 +1,18 @@
 2020-04-23  Jonathan Wakely  <jwakely@redhat.com>
 
+       Backport from mainline
+       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): Update
        value to indicate P0858R0 support.
        * include/std/string_view (__cpp_lib_string_view): Likewise.
index 2d821e5c624d193a5c268a69d28065a31c7dcc25..9f941c5e2f48659cd600799c9713330c413f20ec 100644 (file)
@@ -50,6 +50,7 @@
 
 // Feature test macro for parallel algorithms
 # define __cpp_lib_parallel_algorithm 201603L
+# define __cpp_lib_execution 201902L
 
 #endif // C++17
 
index c54f6ffbb4c958ff775e3ea5eb60b4332464ddc7..0f704c054cfa6941164d5e95d875eb7f2ee834ff 100644 (file)
 #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
 #if _GLIBCXX_HOSTED
 #define __cpp_lib_assume_aligned 201811L
 #define __cpp_lib_bind_front 201907L
+// FIXME: #define __cpp_lib_execution 201902L
 #define __cpp_lib_constexpr_complex 201711L
 #define __cpp_lib_constexpr_memory 201811L
 #define __cpp_lib_erase_if 202002L
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 (file)
index 0000000..3e74f89
--- /dev/null
@@ -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 (file)
index 0000000..4d75a18
--- /dev/null
@@ -0,0 +1,35 @@
+// 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 } }
+// { dg-require-effective-target tbb-backend }
+
+#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 (file)
index 0000000..e7bbf92
--- /dev/null
@@ -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 (file)
index 0000000..2d99195
--- /dev/null
@@ -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
index d9d558b9deaefb0f118b6c7c8789342f372a7ab3..c6408f523e07b73dfe7693214049d09ddfdbf581 100644 (file)
 
 #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